#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
const int maxn = 500005;
int num[maxn];
int a[maxn], b[maxn], c[maxn];
int col[maxn];
int p[maxn];
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];
}
int max(int a, int b) { return a > b ? a : b; }
int lowbit(int x) { return x & (-x); }
void update(int pos, int v) {
  while (pos > 0) {
    col[pos] = max(col[pos], v);
    pos -= lowbit(pos);
  }
}
int query(int pos) {
  int ans = 0;
  while (pos <= maxn) {
    ans = max(ans, col[pos]);
    pos += lowbit(pos);
  }
  return ans;
}
int main() {
  int n, i, j, k;
  int ans = 0;
  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);
  for (i = 1; i <= n; i++) a[p[i]] = i;
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp2);
  for (i = 1; i <= n; i++) b[p[i]] = i;
  for (i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + n + 1, cmp3);
  for (i = 1; 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 = n; i >= 1; i--) {
    k = query(b[p[i]]);
    if (k > num[b[p[i]]]) ans++;
    update(b[p[i]], num[b[p[i]]]);
  }
  printf("%d\n", ans);
  return 0;
}
