#include <bits/stdc++.h>
using namespace std;
class ty {
 public:
  int left, right, mid, max;
};
class ee {
 public:
  int a, b, c;
};
ee data[500000 + 88];
ty tree[2000000];
bool cmp(ee x, ee y) { return x.a > y.a; }
void build(int a, int b, int root) {
  tree[root].left = a;
  tree[root].right = b;
  tree[root].max = -1;
  tree[root].mid = (a + b) >> 1;
  if (a != b) {
    build(a, tree[root].mid, root * 2);
    build(tree[root].mid + 1, b, root * 2 + 1);
  }
}
int yr[500008], p, len;
int b_search(int a, int b, int num) {
  int mid;
  while (a <= b) {
    mid = (a + b) >> 1;
    if (yr[mid] == num) return mid;
    if (yr[mid] > num) {
      b = mid - 1;
    } else
      a = mid + 1;
  }
  return mid;
}
int getvalue(int root, int a) {
  if (tree[root].left == tree[root].right) {
    return tree[root].max;
  } else if (a > tree[root].mid) {
    return getvalue(root * 2 + 1, a);
  } else {
    int c = getvalue(root * 2, a);
    int d = tree[root * 2 + 1].max;
    return c > d ? c : d;
  }
}
void insert(int root, int a, int c) {
  if (tree[root].left == tree[root].right) {
    if (c > tree[root].max) tree[root].max = c;
    return;
  }
  if (a > tree[root].mid) {
    insert(root * 2 + 1, a, c);
  } else {
    insert(root * 2, a, c);
  }
  tree[root].max = tree[root * 2].max > tree[root * 2 + 1].max
                       ? tree[root * 2].max
                       : tree[root * 2 + 1].max;
}
int n, ans;
int main() {
  scanf("%d", &n);
  int i, j, k;
  for (i = 1; i <= n; i++) scanf("%d", &data[i].a);
  for (i = 1; i <= n; i++) scanf("%d", &data[i].b);
  for (i = 1; i <= n; i++) scanf("%d", &data[i].c);
  for (i = 1; i <= n; i++) {
    yr[++len] = data[i].b;
  }
  sort(yr + 1, yr + len + 1);
  sort(data + 1, data + 1 + n, cmp);
  int a = 1, b = 1;
  while (b <= len) {
    while (b <= len && yr[b] == yr[a]) {
      b++;
    }
    if (b <= len) {
      yr[++a] = yr[b];
    }
  }
  len = a;
  build(1, len + 3, 1);
  ans = 0;
  int u;
  for (i = 1; i <= n; i++) {
    j = i;
    for (j = i; j <= n; j++)
      if (data[j].a != data[i].a) break;
    j--;
    for (k = i; k <= j; k++) {
      data[k].b = b_search(1, len, data[k].b);
      u = getvalue(1, data[k].b + 1);
      if (u > data[k].c) ans++;
    }
    for (k = i; k <= j; k++) insert(1, data[k].b, data[k].c);
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}
