#include <bits/stdc++.h>
using namespace std;
long long spf[300001];
long long fac[300001];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 300001; i++) spf[i] = i;
  for (long long i = 4; i < 300001; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 300001; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 300001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
long long ncr(long long n, long long r, long long p) {
  if (r == 0) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
long long seg[4000009] = {0};
void update(long long v, long long l, long long r, long long pos,
            long long val) {
  if (l == r) {
    seg[v] = max(val, seg[v]);
    return;
  }
  long long mid = (l + r) / 2;
  if (pos <= mid)
    update(v * 2, l, mid, pos, val);
  else
    update(v * 2 + 1, mid + 1, r, pos, val);
  seg[v] = max(seg[v * 2], seg[v * 2 + 1]);
}
long long query(long long v, long long l, long long r, long long posl,
                long long posr) {
  if (l >= posl && r <= posr)
    return seg[v];
  else if (l > posr || r < posl)
    return 0;
  long long mid = (l + r) / 2;
  return max(query(v * 2, l, mid, posl, posr),
             query(v * 2 + 1, mid + 1, r, posl, posr));
}
void solve() {
  long long n;
  cin >> n;
  set<long long> s;
  map<long long, vector<pair<long long, long long> >, greater<long long> > m;
  long long ans = 0;
  long long B[n + 1], I[n + 1], R[n + 1];
  for (long long i = 1; i <= n; i++) cin >> B[i];
  for (long long i = 1; i <= n; i++) {
    cin >> I[i];
    s.insert(I[i]);
  }
  for (long long i = 1; i <= n; i++) cin >> R[i];
  for (long long i = 1; i <= n; i++) {
    m[B[i]].push_back(make_pair(I[i], R[i]));
  }
  long long siz = s.size();
  long long a[siz + 1];
  long long i = 1;
  a[0] = -1;
  for (auto it : s) {
    a[i] = it;
    i++;
    if (i == siz + 1) break;
  }
  s.clear();
  for (auto it : m) {
    for (auto it2 : m[it.first]) {
      auto it3 = lower_bound(a, a + siz + 1, it2.first) - a;
      long long flag = 0;
      flag = query(1, 1, siz + 1, it3 + 1, siz + 1);
      if (flag > it2.second) ans++;
    }
    for (auto it2 : m[it.first]) {
      auto it3 = lower_bound(a, a + siz + 1, it2.first) - a;
      update(1, 1, siz + 1, it3, it2.second);
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test = 1;
  while (test--) {
    solve();
  }
}
