#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int c[500050], cnt, n, ans;
struct Node {
  int b, i, r, id;
} a[500050];
inline void add(int x, int d) {
  while (x > 0) {
    if (c[x] < d) c[x] = d;
    x -= x & (-x);
  }
}
inline int getmax(int x) {
  int res = -1;
  for (int i = x; i <= cnt; i += i & (-i))
    if (res < c[i]) res = c[i];
  return res;
}
inline bool cmp(Node a, Node b) { return a.b < b.b; }
inline bool cmp1(Node a, Node b) { return a.i > b.i; }
signed main() {
  n = read();
  int i, j;
  for (i = 0; i < n; i++) a[i].b = read();
  for (i = 0; i < n; i++) a[i].i = read();
  for (i = 0; i < n; i++) a[i].r = read();
  sort(a, a + n, cmp);
  cnt = 1;
  a[0].id = 1;
  for (i = 1; i < n; i++)
    if (a[i].b == a[i - 1].b)
      a[i].id = cnt;
    else
      a[i].id = ++cnt;
  sort(a, a + n, cmp1);
  for (i = 1; i <= cnt; i++) c[i] = -1;
  for (i = 0; i < n;) {
    for (j = i; j < n && a[i].i == a[j].i; j++)
      if (getmax(a[j].id + 1) > a[j].r) ans++;
    for (j = i; j < n && a[i].i == a[j].i; j++) add(a[j].id, a[j].r);
    i = j;
  }
  printf("%d", ans);
  return 0;
}
