#include <bits/stdc++.h>
using namespace std;
struct dame {
  int b, i, r;
  dame() {}
  dame(int b_, int i_, int r_) : b(b_), i(i_), r(r_) {}
};
bool greater_compare(dame A, dame B) {
  return A.b > B.b || A.b == B.b && A.i < B.i ||
         A.b == B.b && A.i == B.i && A.r < B.r;
}
bool by_i(dame a, dame b) { return a.i < b.i; }
int size = 2;
vector<int> tree;
void update(int pos, int value) {
  pos += size;
  if (value <= tree[pos]) return;
  tree[pos] = value;
  pos /= 2;
  while (pos > 0) {
    tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);
    pos /= 2;
  }
}
int getmax(int l, int r, int i = 1, int a = 0, int b = size - 1) {
  if (l > r) return 0;
  if (l == a && r == b) return tree[i];
  int center = (a + b) / 2;
  if (r <= center) return getmax(l, r, i * 2, a, center);
  if (l > center) return getmax(l, r, i * 2 + 1, center + 1, b);
  return max(getmax(l, center, i * 2, a, center),
             getmax(center + 1, r, i * 2 + 1, center + 1, b));
}
int main() {
  int n, answer = 0;
  scanf("%d", &n);
  while (size < n) size *= 2;
  vector<dame> dames(n);
  tree = vector<int>(size * 2, 0);
  for (int i = 0; i < n; i++) scanf("%d", &dames[i].b);
  for (int i = 0; i < n; i++) scanf("%d", &dames[i].i);
  for (int i = 0; i < n; i++) scanf("%d", &dames[i].r);
  sort(dames.begin(), dames.end(), by_i);
  int compress_val = -1, prev = -1;
  for (int i = 0; i < n; i++) {
    if (dames[i].i != prev) compress_val++;
    prev = dames[i].i;
    dames[i].i = compress_val;
  }
  sort(dames.begin(), dames.end(), greater_compare);
  for (int i = 0; i < n; i++) {
    int max_r = getmax(dames[i].i + 1, n - 1);
    if (max_r > dames[i].r) answer++;
    update(dames[i].i, dames[i].r);
  }
  printf("%d\n", answer);
}
