#include <bits/stdc++.h>
using namespace std;
int n;
struct point {
  int x, y, z;
} a[(int)5e5 + 1];
int bit[(int)5e5 + 10];
void add(int id, int value) {
  for (; id < (int)5e5 + 10; id += (id & (-id))) bit[id] = max(bit[id], value);
}
int sum(int id) {
  int ans = -1;
  for (; id > 0; id -= (id & (-id))) ans = max(ans, bit[id]);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> y(n), z(n);
  for (int i = 0; i < n; i++) cin >> a[i].x;
  for (int i = 0; i < n; i++) {
    cin >> a[i].y;
    y[i] = a[i].y;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].z;
    z[i] = a[i].z;
  }
  sort(y.begin(), y.end());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  sort(z.begin(), z.end());
  z.resize(unique(z.begin(), z.end()) - z.begin());
  map<int, int> m;
  int k = 0;
  for (int i : z) m[i] = k++;
  for (int i = 0; i < n; i++) a[i].z = m[a[i].z];
  k = y.size();
  m.clear();
  for (int i : y) m[i] = k--;
  for (int i = 0; i < n; i++) a[i].y = m[a[i].y];
  sort(a, a + n, [](point l, point r) { return l.x > r.x; });
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j + 1 < n && a[i].x == a[j + 1].x) j++;
    for (int l = i; l <= j; l++) ans += (sum(a[l].y - 1) > a[l].z);
    for (int l = i; l <= j; l++) add(a[l].y, a[l].z);
    i = j;
  }
  cout << ans << endl;
  return 0;
}
