#include <bits/stdc++.h>
using namespace std;
const long long int maxn = (5e5) + 10, mod = 1e9 + 7;
long long int n, seg[4 * maxn], ans, pnt[4 * maxn];
pair<long long int, pair<long long int, long long int> > a[maxn];
pair<long long int, long long int> ne[maxn];
void upd(long long int pos, long long int num, long long int s = 0,
         long long int e = maxn, long long int id = 1) {
  if (s == e - 1) {
    seg[id] = max(seg[id], num);
    return;
  }
  long long int mid = (s + e) >> 1;
  if (pos < mid)
    upd(pos, num, s, mid, 2 * id);
  else
    upd(pos, num, mid, e, 2 * id + 1);
  seg[id] = max(seg[2 * id], seg[2 * id + 1]);
}
long long int get(long long int l, long long int r, long long int s = 0,
                  long long int e = maxn, long long int id = 1) {
  if (r <= s || e <= l) return 0;
  if (l <= s && e <= r) return seg[id];
  long long int mid = (s + e) >> 1;
  return max(get(l, r, s, mid, 2 * id), get(l, r, mid, e, 2 * id + 1));
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i].first;
  for (long long int i = 0; i < n; i++) cin >> a[i].second.first;
  for (long long int i = 0; i < n; i++) cin >> a[i].second.second;
  sort(a, a + n);
  for (long long int i = 0; i < n; i++) ne[i] = make_pair(a[i].second.first, i);
  sort(ne, ne + n);
  for (long long int i = 0; i < n; i++) {
    if (i > 0 && ne[i].first == ne[i - 1].first)
      pnt[ne[i].second] = pnt[ne[i - 1].second];
    else
      pnt[ne[i].second] = i;
  }
  vector<long long int> v;
  for (long long int i = n - 1; i >= 0; i--) {
    long long int j = i;
    while (j != 0 && a[j].first == a[j - 1].first) {
      long long int res = get(pnt[j] + 1, maxn);
      if (res > a[j].second.second) ans++;
      j--;
    }
    long long int res = get(pnt[j] + 1, maxn);
    if (res > a[j].second.second) ans++;
    long long int k = i;
    while (k != 0 && a[k].first == a[k - 1].first) {
      upd(pnt[k], a[k].second.second);
      k--;
    }
    upd(pnt[k], a[k].second.second);
    i = j;
  }
  cout << ans << endl;
  return 0;
}
