/*
ID: untamed
PROG: Numeric sequences
LANG: C++
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<limits>
#include<climits>
#include<cmath>
#include<functional>
#include<ctime>
#include<cstdlib>
#include<fstream>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef short int i16;
typedef unsigned long long int u64;
typedef unsigned int u32;
typedef unsigned short int u16;
typedef unsigned char u8;
const int N = 1<<17;
int first[N],second[N],third[N];//Here I store the number of occurrences of each number in each column
bool here[N];//here[i] is true if we haven't removed the i-th column yet
int a[4][N];
int n;
void input() {
scanf("%d", &n);
int i;
for(i=1;i<=n;i++) {
scanf("%d", &a[1][i]);
first[a[1][i]]++;
}
for(i=1;i<=n;i++) {
scanf("%d", &a[2][i]);
second[a[2][i]]++;
}
for(i=1;i<=n;i++) {
scanf("%d", &a[3][i]);
third[a[3][i]]++;
}
for(i=1;i<=n;i++) {
here[i]=true;
}
}
void solve() {
int i;
int ans=0;
bool action=true;
while(action==true) {
action=false;
for(i=1;i<=n;i++) {
if(here[i]==false) //Removed
continue;
if(second[a[1][i]]==0 || third[a[1][i]]==0
|| first[a[2][i]]==0 || third[a[2][i]]==0
|| first[a[3][i]]==0 || second[a[3][i]]==0) { //Forced column
ans++;
action=true;
here[i]=false;
first[a[1][i]]--;
second[a[2][i]]--;
third[a[3][i]]--;
}
}
}
printf("%d\n", ans);
}
int main() {
input();
solve();
return 0;
}
LyoKSUQ6IHVudGFtZWQKUFJPRzogTnVtZXJpYyBzZXF1ZW5jZXMKTEFORzogQysrCiovCgojaW5jbHVkZTxjc3RkaW8+CiNpbmNsdWRlPGlvc3RyZWFtPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8Y3N0cmluZz4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxzdGFjaz4KI2luY2x1ZGU8cXVldWU+CiN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VtpXV0rKzsKICAgIH0KICAgIGZvcihpPTE7aTw9bjtpKyspIHsKICAgICAgICBzY2FuZigiJWQiLCAmYVszXVtpXSk7CiAgICAgICAgdGhpcmRbYVszXVtpXV0rKzsKICAgIH0KICAgIGZvcihpPTE7aTw9bjtpKyspIHsKICAgICAgICBoZXJlW2ldPXRydWU7CiAgICB9Cn0KCnZvaWQgc29sdmUoKSB7CiAgICBpbnQgaTsKICAgIGludCBhbnM9MDsKICAgIGJvb2wgYWN0aW9uPXRydWU7CiAgICB3aGlsZShhY3Rpb249PXRydWUpIHsKICAgICAgICBhY3Rpb249ZmFsc2U7CiAgICAgICAgZm9yKGk9MTtpPD1uO2krKykgewogICAgICAgICAgICBpZihoZXJlW2ldPT1mYWxzZSkgLy9SZW1vdmVkCiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgaWYoc2Vjb25kW2FbMV1baV1dPT0wIHx8IHRoaXJkW2FbMV1baV1dPT0wCiAgICAgICAgICAgIHx8IGZpcnN0W2FbMl1baV1dPT0wIHx8IHRoaXJkW2FbMl1baV1dPT0wCiAgICAgICAgICAgIHx8IGZpcnN0W2FbM11baV1dPT0wIHx8IHNlY29uZFthWzNdW2ldXT09MCkgeyAvL0ZvcmNlZCBjb2x1bW4KICAgICAgICAgICAgICAgIGFucysrOwogICAgICAgICAgICAgICAgYWN0aW9uPXRydWU7CiAgICAgICAgICAgICAgICBoZXJlW2ldPWZhbHNlOwogICAgICAgICAgICAgICAgZmlyc3RbYVsxXVtpXV0tLTsKICAgICAgICAgICAgICAgIHNlY29uZFthWzJdW2ldXS0tOwogICAgICAgICAgICAgICAgdGhpcmRbYVszXVtpXV0tLTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHByaW50ZigiJWRcbiIsIGFucyk7Cn0KCmludCBtYWluKCkgewogICAgaW5wdXQoKTsKICAgIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQo=