#include <bits/stdc++.h>
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
using namespace std;
constexpr int inf = 1e9 + 7, base = 541;
constexpr int mod = 1e9 + 7, N = 5e5 + 7;
int a[3][N], rnk[3][N], n;
int seg[4 * N];
void add(int x, int pos, int tag = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[tag] = max(seg[tag], x);
    return;
  }
  int mid = (s + e) / 2, L = tag * 2, R = L + 1;
  if (pos < mid)
    add(x, pos, L, s, mid);
  else
    add(x, pos, R, mid, e);
  seg[tag] = max(seg[L], seg[R]);
}
int find(int l, int r = n, int tag = 1, int s = 0, int e = n) {
  if (s >= r || e <= l) return 0;
  if (s >= l && e <= r) return seg[tag];
  int mid = (s + e) / 2, L = tag * 2, R = L + 1;
  return max(find(l, r, R, mid, e), find(l, r, L, s, mid));
}
int p[N];
int32_t main() {
  n = in();
  vector<pair<int, int> > vec, sec, tec;
  for (int i = 0; i < n; i++) {
    a[0][i] = in();
    vec.push_back({a[0][i], i});
  }
  for (int i = 0; i < n; i++) {
    a[1][i] = in();
    sec.push_back({a[1][i], i});
  }
  for (int i = 0; i < n; i++) {
    a[2][i] = in();
    tec.push_back({a[2][i], i});
  }
  sort(vec.begin(), vec.end());
  sort(sec.begin(), sec.end());
  sort(tec.begin(), tec.end());
  for (int i = n - 1; ~i; --i) {
    if (i != n - 1 && sec[i].first == sec[i + 1].first)
      p[sec[i].second] = p[sec[i + 1].second];
    else
      p[sec[i].second] = i;
  }
  cerr << endl;
  int ans = 0;
  for (int i = n - 1; i >= 0;) {
    int x = vec[i].first;
    vector<int> v;
    while (i >= 0 && vec[i].first == x) v.push_back(vec[i].second), i--;
    for (auto j : v) {
      if (find(p[j] + 1) > a[2][j]) ans++;
    }
    for (auto j : v) add(a[2][j], p[j]);
  }
  cout << ans << endl;
}
