#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
typedef struct p *po;
struct p {
  int p[3];
};
int N;
struct p ps[500001];
po ord[500001];
po temp[500001];
int tree[2400000];
int query(int at, int s, int e, int qS, int qE) {
  if (s == qS && e == qE) {
    return tree[at];
  }
  int m = (s + e) / 2;
  int res = -1;
  if (qS < m) {
    res = max(res, query(at * 2, s, m, qS, min(qE, m)));
  }
  if (qE > m) {
    res = max(res, query(at * 2 + 1, m, e, max(qS, m), qE));
  }
  return res;
}
void update(int at, int s, int e, int p, int v) {
  if (e - s == 1) {
    tree[at] = max(tree[at], v);
  } else {
    int m = (s + e) / 2;
    if (p < m) {
      update(at * 2, s, m, p, v);
    } else {
      update(at * 2 + 1, m, e, p, v);
    }
    tree[at] = max(tree[at * 2], tree[at * 2 + 1]);
  }
}
void sort(int s, int e, int pl) {
  if (e - s <= 1) {
    return;
  }
  int m = (s + e) / 2;
  sort(s, m, pl);
  sort(m, e, pl);
  int i;
  int p1 = s;
  int p2 = m;
  for (i = 0; i < e - s; i++) {
    if (p2 == e || (p1 < m && ord[p1]->p[pl] < ord[p2]->p[pl])) {
      temp[i] = ord[p1++];
    } else {
      temp[i] = ord[p2++];
    }
  }
  for (i = 0; i < e - s; i++) {
    ord[s + i] = temp[i];
  }
}
int main() {
  scanf("%d ", &N);
  int i, j;
  for (i = 0; i < N; i++) {
    scanf("%d ", &ps[i].p[0]);
    ord[i] = &ps[i];
  }
  for (i = 0; i < N; i++) {
    scanf("%d ", &ps[i].p[1]);
  }
  for (i = 0; i < N; i++) {
    scanf("%d ", &ps[i].p[2]);
  }
  sort(0, N, 1);
  int upTo = 0;
  for (i = 0; i < N - 1; i++) {
    if (ord[i]->p[1] == ord[i + 1]->p[1]) {
      ord[i]->p[1] = upTo;
    } else {
      ord[i]->p[1] = upTo++;
    }
  }
  ord[i]->p[1] = upTo;
  sort(0, N, 0);
  int invalid = 0;
  for (i = N - 1; i >= 0;) {
    for (j = i; j >= 0 && ord[j]->p[0] == ord[i]->p[0]; j--) {
      int res = query(1, 0, N + 1, ord[j]->p[1] + 1, N + 1);
      if (res > ord[j]->p[2]) {
        invalid++;
      }
    }
    for (j = i; j >= 0 && ord[j]->p[0] == ord[i]->p[0]; j--) {
      update(1, 0, N + 1, ord[j]->p[1], ord[j]->p[2]);
    }
    i = j;
  }
  printf("%d\n", invalid);
  return 0;
}
