#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, c, id;
} ld[500005], fw[500005];
int n;
bool cmp(node x, node y) { return x.a > y.a || (x.a == y.a && x.c < y.c); }
int ans, t[500005], bk[500005], zz, f[500005];
void cler(int x) {
  while (x <= zz) {
    t[x] = 0;
    x += x & (-x);
  }
}
void add(int x) {
  while (x <= zz) {
    ++t[x];
    x += x & (-x);
  }
}
int query(int x) {
  int hc = 0;
  while (x > 0) {
    hc += t[x];
    x -= x & (-x);
  }
  return hc;
}
void solve(int l, int r) {
  if (l == r) return;
  int mid = l + r >> 1, x = l, y = mid + 1, zfw = 0;
  solve(l, mid);
  solve(mid + 1, r);
  while (x <= mid && y <= r) {
    if (ld[x].b > ld[y].b) {
      add(ld[x].c);
      fw[++zfw] = ld[x++];
    } else {
      f[ld[y].id] += x - l - query(ld[y].c);
      fw[++zfw] = ld[y++];
    }
  }
  while (x <= mid) {
    fw[++zfw] = ld[x++];
  }
  while (y <= r) {
    f[ld[y].id] += x - l - query(ld[y].c);
    fw[++zfw] = ld[y++];
  }
  for (int i = l; i <= mid; ++i) cler(ld[i].c);
  for (int i = 1; i <= zfw; ++i) ld[l + i - 1] = fw[i];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &ld[i].a);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &ld[i].b);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &ld[i].c);
    bk[++zz] = ld[i].c;
  }
  sort(bk + 1, bk + 1 + zz);
  zz = unique(bk + 1, bk + 1 + zz) - bk - 1;
  for (int i = 1; i <= n; ++i) {
    ld[i].c = lower_bound(bk + 1, bk + 1 + zz, ld[i].c) - bk;
    ld[i].id = i;
  }
  sort(ld + 1, ld + 1 + n, cmp);
  solve(1, n);
  for (int i = 1; i <= n; ++i)
    if (f[i]) ++ans;
  printf("%d", ans);
  return 0;
}
