#include <bits/stdc++.h>
using namespace std;
struct type {
  int x, y, z, k;
} lady[500005];
int lim[500005], n, leny;
bool sorty(type a, type b) { return (a.k < b.k); }
bool sortall(type a, type b) {
  return ((a.x > b.x) || (a.x == b.x && a.y < b.y) ||
          (a.x == b.x && a.y == b.y && a.z < b.z));
}
void update(int x, int p) {
  while (p > 0) {
    lim[p] = max(x, lim[p]);
    p -= p & -p;
  }
}
int read(int p) {
  int r = 0;
  while (p <= leny + 1) {
    r = max(lim[p], r);
    p += p & -p;
  }
  return r;
}
int main() {
  int i, j, k, cnt = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &lady[i].x);
  for (i = 0; i < n; i++) scanf("%d", &lady[i].k);
  for (i = 0; i < n; i++) scanf("%d", &lady[i].z);
  sort(lady, lady + n, sorty);
  lady[0].y = 1;
  for (i = 1; i < n; i++) {
    lady[i].y = lady[i - 1].y + (lady[i].k != lady[i - 1].k);
  }
  leny = lady[n - 1].y;
  sort(lady, lady + n, sortall);
  for (i = 1; i <= leny + 1; i++) lim[i] = 0;
  for (i = 0; i < n; i++) {
    j = read(lady[i].y);
    k = read(lady[i].y + 1);
    if (lady[i].z > j) {
      update(lady[i].z, lady[i].y);
    }
    if (lady[i].z < k) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
