#include <bits/stdc++.h>
const int N = 500000 + 2;
struct G {
  int B, I, R;
};
struct Seg {
  int mx[N << 2];
  void update(int pos, int v, int l, int r, int rt) {
    if (l == r)
      mx[rt] = std::max(mx[rt], v);
    else {
      int mid = (l + r) >> 1;
      if (pos <= mid)
        update(pos, v, l, mid, rt << 1);
      else
        update(pos, v, mid + 1, r, rt << 1 | 1);
      mx[rt] = std::max(mx[rt << 1], mx[rt << 1 | 1]);
    }
  }
  int query(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R)
      return mx[rt];
    else {
      int mid = (l + r) >> 1;
      if (L > mid)
        return query(L, R, mid + 1, r, rt << 1 | 1);
      else if (R <= mid)
        return query(L, R, l, mid, rt << 1);
      else
        return std::max(query(L, mid, l, mid, rt << 1),
                        query(mid + 1, R, mid + 1, r, rt << 1 | 1));
    }
  }
} sol;
G g[N];
int y[N];
bool cmp(const G& i, const G& j) {
  if (i.B ^ j.B)
    return i.B > j.B;
  else if (i.I ^ j.I)
    return i.I < j.I;
  else
    return i.R < j.R;
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &g[i].B);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &g[i].I);
    y[i] = g[i].I;
  }
  for (int i = 0; i < n; ++i) scanf("%d", &g[i].R);
  std::sort(g, g + n, cmp);
  std::sort(y, y + n);
  m = std::unique(y, y + n) - y;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    g[i].I = std::lower_bound(y, y + m, g[i].I) - y;
    int v = sol.query(g[i].I + 1, m, 0, m, 1);
    if (v > g[i].R) ++ans;
    sol.update(g[i].I, g[i].R, 0, m, 1);
  }
  printf("%d\n", ans);
  return 0;
}
