#include <bits/stdc++.h>
using namespace std;
const long long maxn = 500005;
long long t[4 * maxn];
void update(long long v, long long tl, long long tr, long long pos,
            long long val) {
  if (tl == tr) {
    t[v] = max(t[v], val);
    return;
  }
  long long tm = (tl + tr) / 2;
  if (pos <= tm)
    update(v * 2, tl, tm, pos, val);
  else
    update(v * 2 + 1, tm + 1, tr, pos, val);
  t[v] = max(t[v * 2], t[v * 2 + 1]);
}
long long query(long long v, long long tl, long long tr, long long l,
                long long r) {
  if (r < tl || tr < l || tl > tr || l > r) return 0;
  if (tl >= l && tr <= r) return t[v];
  long long tm = (tl + tr) / 2;
  return max(query(v * 2, tl, tm, l, r), query(v * 2 + 1, tm + 1, tr, l, r));
}
struct lady_node {
  long long a, b, c;
} lady[maxn];
bool cmp(lady_node a, lady_node b) { return a.a > b.a; }
set<long long> s;
map<long long, long long> beauty;
long long id = 1;
long long n;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> lady[i].a;
  for (long long i = 1; i <= n; i++) cin >> lady[i].b, s.insert(lady[i].b);
  for (long long i = 1; i <= n; i++) cin >> lady[i].c;
  for (auto i : s) beauty[i] = id++;
  sort(lady + 1, lady + n + 1, cmp);
  long long i = 1, ans = 0;
  while (i <= n) {
    long long j = i;
    while (j <= n && lady[j].a == lady[i].a) {
      long long beau = beauty[lady[j].b] + 1;
      long long tmp = query(1, 1, n, beau, n);
      if (tmp > lady[j].c) ans++;
      j++;
    }
    while (i < j) {
      update(1, 1, n, beauty[lady[i].b], lady[i].c);
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}
