#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
const int maxn = 500005;
int sum[maxn << 2];
int num[maxn];
int a[maxn], b[maxn], c[maxn];
int p[maxn];
int min(int a, int b) { return a > b ? a : b; }
bool cmp1(int i, int j) {
  if (a[i] == a[j] && b[i] == b[j]) return c[i] > c[j];
  if (a[i] == a[j]) return b[i] > b[j];
  return a[i] < a[j];
}
bool cmp2(int i, int j) {
  if (c[i] == c[j] && b[i] == b[j]) return a[i] > a[j];
  if (b[i] == b[j]) return c[i] > c[j];
  return b[i] < b[j];
}
bool cmp3(int i, int j) {
  if (c[i] == c[j] && b[i] == b[j]) return a[i] > a[j];
  if (c[i] == c[j]) return b[i] > b[j];
  return c[i] < c[j];
}
void push_up(int rt) { sum[rt] = min(sum[rt << 1], sum[rt << 1 | 1]); }
void update(int p, int v, int l, int r, int rt) {
  if (l == r) {
    sum[rt] = min(sum[rt], v);
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m) update(p, v, l, m, rt << 1);
  if (p > m) update(p, v, m + 1, r, rt << 1 | 1);
  push_up(rt);
}
int query(int a, int b, int l, int r, int rt) {
  if (a <= l && r <= b) return sum[rt];
  if (l == r) return 0;
  int m = (l + r) >> 1;
  int ret = 0;
  if (a <= m) ret = min(ret, query(a, b, l, m, rt << 1));
  if (b > m) ret = min(ret, query(a, b, m + 1, r, rt << 1 | 1));
  push_up(rt);
  return ret;
}
int main() {
  int n, i, j, k;
  int ans = 0;
  memset(sum, 0, sizeof(sum));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  for (i = 1; i <= n; i++) scanf("%d", b + i);
  for (i = 1; i <= n; i++) scanf("%d", c + i);
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp1);
  a[p[1]] = 1;
  for (i = 2; i <= n; i++) a[p[i]] = i;
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp2);
  b[p[1]] = 1;
  for (i = 2; i <= n; i++) b[p[i]] = i;
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp3);
  j = 1;
  c[p[1]] = 1;
  for (i = 2; i <= n; i++) c[p[i]] = i;
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp1);
  for (i = 1; i <= n; i++) num[b[i]] = c[i];
  for (i = 1; i <= (maxn * 4); i++) sum[i] = 0;
  for (i = n; i >= 1; i--) {
    k = query(b[p[i]], n, 1, n, 1);
    if (k > num[b[p[i]]]) ans++;
    update(b[p[i]], num[b[p[i]]], 1, n, 1);
  }
  printf("%d\n", ans);
  return 0;
}
