#include <bits/stdc++.h>
using namespace std;
const int N = 500 * 1000 + 20;
int n, a[N], b[N], c[N], seg[N << 2], ans;
vector<pair<int, int> > vec[N];
void compress() {
  vector<int> v[3];
  for (int i = 0; i < n; i++) {
    v[0].push_back(a[i]);
    v[1].push_back(b[i]);
    v[2].push_back(c[i]);
  }
  for (int i = 0; i < 3; i++) {
    sort(v[i].begin(), v[i].end());
    v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
  }
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(v[0].begin(), v[0].end(), a[i]) - v[0].begin();
    b[i] = lower_bound(v[1].begin(), v[1].end(), b[i]) - v[1].begin();
    c[i] = lower_bound(v[2].begin(), v[2].end(), c[i]) - v[2].begin();
    vec[a[i]].push_back(pair<int, int>(b[i], c[i]));
  }
}
void update(int idx, int val, int id = 1, int st = 0, int en = N) {
  if (en - st == 1) {
    seg[id] = max(seg[id], val);
    return;
  }
  int mid = st + en >> 1;
  if (idx < mid)
    update(idx, val, id << 1, st, mid);
  else
    update(idx, val, id << 1 | 1, mid, en);
  seg[id] = max(seg[id << 1], seg[id << 1 | 1]);
}
int get(int l, int r, int id = 1, int st = 0, int en = N) {
  if (r <= st || en <= l) return 0;
  if (l <= st && en <= r) return seg[id];
  int mid = st + en >> 1;
  return max(get(l, r, id << 1, st, mid), get(l, r, id << 1 | 1, mid, en));
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  compress();
  for (int i = N - 1; ~i; i--) {
    for (auto j : vec[i]) ans += (get(j.first + 1, N) > j.second);
    for (auto j : vec[i]) update(j.first, j.second);
  }
  return cout << ans << "\n", 0;
}
