#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000 + 5;
struct Lady {
  int B, I, R;
  bool operator<(const Lady &l) const {
    if (B != l.B) return B > l.B;
    if (I != l.I) return I < l.I;
    return R < l.R;
  }
};
int main() {
  int N;
  scanf("%d", &N);
  vector<Lady> ladies(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &ladies[i].B);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &ladies[i].I);
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &ladies[i].R);
  }
  sort(ladies.begin(), ladies.end());
  int ans = 0;
  map<int, int> left;
  left[INF] = -INF;
  left[-INF] = INF;
  for (int i = 0; i < N; i++) {
    int I = ladies[i].I;
    int R = ladies[i].R;
    map<int, int>::iterator it = left.upper_bound(I);
    if (it != left.end() && R < it->second)
      ans++;
    else if (left.count(I) == 0 || left[I] < R) {
      left[I] = R;
      for (it = --left.lower_bound(I); it->second < R;) {
        left.erase(it--);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
