#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int B;
  int I;
  int R;
  bool die;
} Lady;
int tree[500005];
int n;
Lady ladies[500005];
Lady temp[500005];
int ranks[500005];
bool cmp(Lady a, Lady b) {
  if (a.B == b.B)
    return a.I < b.I;
  else
    return a.B < b.B;
}
void CDQ(int l, int r) {
  if (ladies[l].B == ladies[r].B) return;
  if (l >= r) return;
  int mid = (l + r) / 2;
  int rmin = ladies[mid + 1].B;
  CDQ(l, mid);
  CDQ(mid + 1, r);
  int p1 = mid;
  int p2 = r;
  int r2 = r;
  int maxR1 = -1;
  int maxR2 = -1;
  while (p1 >= l && p2 >= mid + 1) {
    if (ladies[p2].I > ladies[p1].I) {
      if (ladies[p2].B == rmin) {
        if (ladies[p2].R > maxR2) maxR2 = ladies[p2].R;
      } else {
        if (ladies[p2].R > maxR1) maxR1 = ladies[p2].R;
      }
      temp[r2] = ladies[p2];
      p2--;
      r2--;
    } else {
      if (ladies[p1].B == rmin) {
        if (ladies[p1].R < maxR1) ladies[p1].die = true;
      } else if (ladies[p1].R < maxR1 || ladies[p1].R < maxR2)
        ladies[p1].die = true;
      temp[r2] = ladies[p1];
      p1--;
      r2--;
    }
  }
  while (p1 >= l) {
    if (ladies[p1].B == rmin) {
      if (ladies[p1].R < maxR1) ladies[p1].die = true;
    } else if (ladies[p1].R < maxR1 || ladies[p1].R < maxR2)
      ladies[p1].die = true;
    p1--;
  }
  while (p2 >= mid + 1) {
    temp[r2] = ladies[p2];
    r2--;
    p2--;
  }
  r2++;
  while (r2 <= r) {
    ladies[r2] = temp[r2];
    r2++;
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &ladies[i].B);
  for (int i = 1; i <= n; i++) scanf("%d", &ladies[i].I);
  for (int i = 1; i <= n; i++) scanf("%d", &ladies[i].R);
  sort(ladies + 1, ladies + n + 1, cmp);
  CDQ(1, n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (ladies[i].die) cnt++;
  }
  cout << cnt;
  return 0;
}
