#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int B[N], I[N], R[N];
int F[N];
map<int, int> mp;
map<int, int>::iterator it;
void modify(int p[], int h[], int n) {
  for (int i = 1; i <= n; i++) h[i] = p[i];
  sort(h + 1, h + 1 + n);
  int cnt = unique(h + 1, h + 1 + n) - (h + 1);
  for (int i = 1; i <= n; i++) {
    p[i] = lower_bound(h + 1, h + 1 + cnt, p[i]) - h;
  }
}
struct node {
  int bb, ii, rr;
  friend bool operator<(const node n1, const node n2) {
    if (n1.bb != n2.bb) return n1.bb < n2.bb;
    if (n1.ii != n2.ii) return n1.ii > n2.ii;
    if (n1.rr != n2.rr) return n1.rr < n2.rr;
  }
} a[N];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &B[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &I[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &R[i]);
  modify(B, F, n);
  modify(I, F, n);
  modify(R, F, n);
  for (int i = 1; i <= n; i++) {
    a[i].bb = B[i];
    a[i].ii = I[i];
    a[i].rr = R[i];
  }
  sort(a + 1, a + 1 + n);
  mp[1e9] = -1e9, mp[-1e9] = 1e9;
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    it = mp.upper_bound(a[i].ii);
    if (it->second > a[i].rr)
      ans++;
    else if (mp[a[i].ii] < a[i].rr) {
      mp[a[i].ii] = a[i].rr;
      for (it = --mp.lower_bound(a[i].ii); it->second < a[i].rr;)
        mp.erase(it--);
    }
  }
  printf("%d\n", ans);
  return 0;
}
