#include <bits/stdc++.h>
using namespace std;
struct lady {
  int b, i, r;
} a[500005];
bool operator<(const lady& a, const lady& b) {
  if (a.b != b.b) return a.b > b.b;
  if (a.i != b.i) return a.i < b.i;
  return a.r < b.r;
}
int n;
void inp() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].b);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].i);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].r);
}
set<int> s;
int x[500005], m;
void ready() {
  for (int i = 1; i <= n; ++i) s.insert(a[i].i);
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    x[++m] = *it;
}
int bi[500005], ans;
inline void update(int u, int val) {
  u = lower_bound(x + 1, x + m + 1, u) - x;
  for (; u; u &= u - 1) bi[u] = max(bi[u], val);
}
inline int get(int u) {
  u = lower_bound(x + 1, x + m + 1, u) - x;
  int res = 0;
  for (; u <= m; u += u & -u) res = max(res, bi[u]);
  return res;
}
void solve() {
  ready();
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    ans += get(a[i].i + 1) > a[i].r;
    update(a[i].i, a[i].r);
  }
  printf("%d\n", ans);
}
int main() {
  srand(time(NULL));
  inp();
  solve();
  return 0;
}
