#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 20;
int B[MAX], I[MAX], R[MAX], order[MAX], tmp[MAX], tree[MAX], n;
int cmpOrder(int a, int b) {
  if (B[a] != B[b]) return B[a] > B[b];
  if (I[a] != I[b]) return I[a] < I[b];
  return R[a] < R[b];
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> B[i];
  for (int i = 0; i < n; i++) cin >> I[i];
  for (int i = 0; i < n; i++) cin >> R[i];
  for (int i = 0; i < n; i++) order[i] = i;
  sort(order, order + n, cmpOrder);
}
void preSolve(int r[]) {
  for (int i = 0; i < n; i++) tmp[i] = -r[i];
  sort(tmp, tmp + n);
  int sz = unique(tmp, tmp + n) - tmp;
  for (int i = 0; i < n; i++) r[i] = lower_bound(tmp, tmp + sz, -r[i]) - tmp;
}
void treeInit() {
  for (int i = 1; i <= n; i++) tree[i] = -1;
}
int getMax(int pos) {
  int rt = -1;
  while (pos) {
    rt = max(tree[pos], rt);
    pos -= ((pos) & (-pos));
  }
  return rt;
}
void add(int pos, int d) {
  ++pos;
  while (pos <= n) {
    tree[pos] = max(d, tree[pos]);
    pos += ((pos) & (-pos));
  }
}
int solve() {
  preSolve(I);
  treeInit();
  int rt = 0;
  for (int i = 0; i < n; i++) {
    int u = order[i];
    if (getMax(I[u]) > R[u]) rt++;
    add(I[u], R[u]);
  }
  return rt;
}
int main() {
  input();
  cout << solve() << endl;
  return 0;
}
