(*
	IV окружной этап Всероссийской олимпиады школьников по информатике
	24 - 28 марта 2006 г.
	г. Петрозаводск

	Задача F. Студенческие годы Пекки
	Авторы: А. Лопатин, В. Кузнецов
	Решение: А. Лопатин
*)

{$O-,Q+,R+}
{$APPTYPE CONSOLE}
uses SysUtils;

const HSize=239017;
      MaxN=100000;
      MaxL=10;

var H:array [0..HSize-1] of string;

function hash (const s:string; allowadd:boolean):integer;
var h1, h2, i:integer;
begin
  h1:=0; h2:=0;
  for i:=1 to length (s) do begin
    h1:=h1*3+ord (s[i]); while h1>=HSize do dec (h1, HSize);
    h2:=h2*5+ord (s[i]); while h2>=HSize-1 do dec (h2, HSize-1);
  end;
  inc (h2);
  while H[h1]<>'' do begin
    if H[h1]=s then begin Result:=h1; exit end;
    inc (h1, h2); if h1>=HSize then dec (h1, HSize);
  end;
  assert (allowadd);
  H[h1]:=s; Result:=h1;
end;


var s1, s2:array [1..MaxN] of integer;
    P1, P2:array [1..MaxN] of integer;
    c, Q1, Q2:array [0..HSize-1] of integer;
    i, j, cc, n, l, r, a, b:integer;
    s:string;
    ch:char;

begin
  reset (input, 'train.in'); rewrite (output, 'train.out');
  assert (not seekeoln); read (n); assert ((n>=1) and (n<=MaxN));
  read (ch); assert (ch=#13); read (ch); assert (ch=#10);
  for i:=1 to n do begin
    readln (s);
    assert ((length (s)>=1) and (length (s)<=MaxL));
    for j:=1 to length (s) do assert (s[j] in ['A'..'Z', 'a'..'z']);
    s1[i]:=hash (s, true);
  end;
  for i:=1 to n do begin
    readln (s);
    assert ((length (s)>=1) and (length (s)<=MaxL));
    for j:=1 to length (s) do assert (s[j] in ['A'..'Z', 'a'..'z']);
    s2[i]:=hash (s, false);
  end;
  assert (eof);
  for i:=1 to n do begin
    inc (c[s1[i]]); dec (c[s2[i]]);
  end;
  for cc:=0 to HSize-1 do assert (c[cc]=0);
  for i:=1 to n do begin
    P1[i]:=Q1[s1[i]];
    Q1[s1[i]]:=i;
    P2[i]:=Q2[s2[i]];
    Q2[s2[i]]:=i;
  end;
  l:=0; r:=0;
  for cc:=0 to HSize-1 do begin
    a:=Q1[cc]; b:=Q2[cc];
    while a<>0 do begin
      if a>b then begin
        if a-b>l then l:=a-b;
      end else begin
        if b-a>r then r:=b-a;
      end;
      a:=P1[a];
      b:=P2[b];
    end;
    assert (b=0);
  end;
  if l>r then writeln (2*r+l) else writeln (2*l+r);
end.