#include <bits/stdc++.h>
using namespace std;
struct data {
  int x, y, z;
};
data num[500003];
int tree[4 * 500003], n, numy[500003];
bool cmp(data a, data b) { return a.x > b.x; }
int query(int node, int l, int r, int ql, int qr) {
  if (ql == l && qr == r) return tree[node];
  int mid = (l + r) >> 1;
  if (qr <= mid)
    return query(2 * node, l, mid, ql, qr);
  else if (ql > mid)
    return query(2 * node + 1, mid + 1, r, ql, qr);
  else {
    int x, y;
    x = query(2 * node, l, mid, ql, mid);
    y = query(2 * node + 1, mid + 1, r, mid + 1, qr);
    return max(x, y);
  }
}
void update(int node, int l, int r, int pos, int val) {
  if (l == r) {
    tree[node] = max(tree[node], val);
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(2 * node, l, mid, pos, val);
  else
    update(2 * node + 1, mid + 1, r, pos, val);
  tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
int get(int a) {
  int start = 1, end = n, mid;
  while (start <= end) {
    mid = (start + end) >> 1;
    if (numy[mid] == a)
      return mid;
    else if (numy[mid] < a)
      start = mid + 1;
    else
      end = mid - 1;
  }
}
int main() {
  int i, j, no, pos, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &num[i].x);
  for (i = 1; i <= n; i++) {
    scanf("%d", &num[i].y);
    numy[i] = num[i].y;
  }
  for (i = 1; i <= n; i++) scanf("%d", &num[i].z);
  sort(num + 1, num + n + 1, cmp);
  sort(numy + 1, numy + n + 1);
  no = 0;
  for (i = 1; i <= n; i = j) {
    for (j = i; j <= n && num[i].x == num[j].x; j++) {
      pos = get(num[j].y);
      if (pos == n) continue;
      k = query(1, 1, n, pos + 1, n);
      if (num[j].z < k) no++;
    }
    for (j = i; j <= n && num[i].x == num[j].x; j++) {
      pos = get(num[j].y);
      update(1, 1, n, pos, num[j].z);
    }
  }
  printf("%d\n", no);
  return 0;
}
