program difficult;

var pole : array [0..2, 1..150000] of longint;
var max, i, j, hodnota, pocet : longint;

function max2(a, b : longint) : longint;
begin

	if (a >= b) then
		max2 := a
	else
		max2 := b;

end;

begin

while true do
begin

	readln(max);

	if max = 0 then
		break;

	pocet := 0;
		
	for j:= 0 to 2 do
	begin
	
		for i:=1 to max do
		begin
		
			read(hodnota);
			
			pole[j][hodnota] := i;
		
		end;
		
		readln;
	
	end;
	
	for i:=1 to max do
	begin
	
		pocet := pocet + max - max2(max2(pole[0][i],pole[1][i]),pole[2][i]);
	
	end;
	
	writeln(pocet);
	
end;
	
	{
	for j:= 0 to 2 do
	begin
	
		for i:= 1 to max do
		begin
		
			write(pole[j][i],' ');
		
		end;
		
		writeln;
		
	end; 
	}

end.
