#include <bits/stdc++.h>
using namespace std;
const int maxv = 500005 * 4;
int n;
int tmp[maxv / 4];
struct Node {
  int a, b, c;
} p[maxv / 4];
bool cmp(Node x, Node y) {
  if (x.a != y.a) return x.a > y.a;
  if (x.b != y.b) return x.b > y.b;
  return x.c > y.c;
}
struct Tree {
  int l, r, sum;
};
Tree node[maxv];
void pushup(int i) {
  node[i].sum = max(node[i << 1].sum, node[i << 1 | 1].sum);
}
void bulid(int i, int l, int r) {
  node[i].l = l;
  node[i].r = r;
  if (l == r) {
    node[i].sum = 0;
    return;
  }
  int mid = (l + r) >> 1;
  bulid(i << 1, l, mid);
  bulid(i << 1 | 1, mid + 1, r);
  pushup(i);
}
void update(int i, int k, int x) {
  if (node[i].l == k && node[i].l == node[i].r) {
    node[i].sum = max(node[i].sum, x);
    return;
  }
  int mid = (node[i].l + node[i].r) >> 1;
  if (k <= mid) {
    update(i << 1, k, x);
  } else {
    update(i << 1 | 1, k, x);
  }
  pushup(i);
}
int query(int L, int R, int l, int r, int i) {
  int res = 0;
  if (L <= l && R >= r) {
    return node[i].sum;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) {
    res = max(query(L, R, l, mid, i << 1), res);
  }
  if (R > mid) {
    res = max(query(L, R, mid + 1, r, i << 1 | 1), res);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].a);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].b);
    tmp[i] = p[i].b;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].c);
  }
  sort(tmp + 1, tmp + 1 + n);
  int num = unique(tmp + 1, tmp + 1 + n) - tmp - 1;
  bulid(1, 1, num + 1);
  sort(p + 1, p + 1 + n, cmp);
  int j;
  int ans = 0;
  for (int i = 1; i <= n;) {
    j = i;
    while (i <= n && p[j].a == p[i].a) {
      p[i].b = lower_bound(tmp + 1, tmp + num + 1, p[i].b) - tmp;
      if (p[i].c < query(p[i].b + 1, num + 1, 1, num + 1, 1)) ans++;
      i++;
    }
    while (j < i) {
      update(1, p[j].b, p[j].c);
      j++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
