#include <bits/stdc++.h>
using namespace std;
struct block {
  int x, y, z;
};
const int MN = 5 * 1000 * 100 + 10;
const int inf = 1 << 30;
block arr[MN];
int mx[MN], n;
inline bool byX(block a, block b) { return a.x > b.x; }
inline bool byY(block a, block b) { return a.y > b.y; }
inline void upd(int v, int val) {
  while (v < n) {
    mx[v] = max(mx[v], val);
    v |= (v + 1);
  }
}
inline int get_max(int v) {
  int maxim = -inf;
  while (v >= 0) {
    maxim = max(maxim, mx[v]);
    v = (v & (v + 1)) - 1;
  }
  return maxim;
}
inline void upd_segm(int left, int right) {
  for (int i = left; i <= right; i++) upd(arr[i].y, arr[i].z);
}
int main() {
  int ans = 0;
  fill(&mx[0], &mx[0] + MN, -inf);
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &arr[i].x);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i].y);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i].z);
  sort(arr, arr + n, byY);
  for (int i = 0, prev = -1, j = -1; i < n; i++) {
    if (arr[i].y != prev) {
      prev = arr[i].y;
      arr[i].y = ++j;
    } else
      arr[i].y = j;
  }
  sort(arr, arr + n, byX);
  for (int i = 1, poz = 0; i < n; i++) {
    if (arr[i].x != arr[i - 1].x) {
      upd_segm(poz, i - 1);
      poz = i;
    }
    int maxim = get_max(arr[i].y - 1);
    if (maxim > arr[i].z) ans++;
  }
  cout << ans;
  return 0;
}
