#include <bits/stdc++.h>
using namespace std;
struct tt {
  int x, y, z;
  int cnt;
} per[500100];
bool cc1(const tt& a, const tt& b) { return a.x > b.x; }
int tree[500100];
int MaxVal = 500100 - 10;
int read(int idx) {
  int sum = -(1 << 29);
  while (idx <= MaxVal) {
    sum = max(sum, tree[idx]);
    idx += (idx & -idx);
  }
  return sum;
}
void update(int idx, int val) {
  while (idx > 0) {
    tree[idx] = max(val, tree[idx]);
    idx -= (idx & -idx);
  }
}
map<int, int> mp;
vector<int> v;
int main() {
  int n;
  scanf("%d", &n);
  int a, b, c;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &per[i].x);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &per[i].y);
    v.push_back(per[i].y);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &per[i].z);
    per[i].z++;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (mp.find(v[i]) == mp.end()) mp[v[i]] = i + 1;
  }
  for (int i = 0; i < n; ++i) {
    per[i].y = mp[per[i].y];
  }
  sort(per, per + n, cc1);
  int prv = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (per[i].z < read(per[i].y + 1)) {
      ans++;
    }
    if (i + 1 == n || per[i + 1].x != per[i].x) {
      for (int j = prv; j <= i; ++j) {
        update(per[j].y, per[j].z);
      }
      prv = i + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
