import java.util.*;
import java.io.*;

public class difficult {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long count;
        int cols;
        int[][] pole;
        
        while(sc.hasNext()){
            cols = sc.nextInt();
            if(cols==0) break;
            
            pole = new int[3][cols];
            for(int o=0; o<3; o++) {
                for(int p=0; p<cols; p++) {
                    pole[o][p] = sc.nextInt();
                }
            }
            
            count = 0;
            
            boolean[] b;
            
            for(int i=0; i<cols; i++) {
                b = new boolean[cols];
                for(int k=0; k<=i; k++) {
                    b[pole[0][k]-1] = true;
                }
                for(int m=0; m<cols; m++) {
                    if(pole[1][m] != pole[0][i]) b[pole[1][m]-1] = true;
                    else break;
                }
                for(int m=0; m<cols; m++) {
                    if(pole[2][m] != pole[0][i]) b[pole[2][m]-1] = true;
                    else break;
                }
                
                for(int m=0; m<cols; m++) {
                    if(!b[m]) {
                        count++;
                    }
                }
                //System.out.println(count + ", ");
            }
            
            
            System.out.print(count + "\n");
        }
    }
}