#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535;
const double eps = 1e-6;
struct TE {
  int a, b, c;
} E[501000];
int tr[501000], n, x[501000], m;
bool cmp(TE a, TE b) { return a.a < b.a; }
int low(int a) { return (a & (-a)); }
int ask(int a) {
  int ret = 1992837465;
  while (a) {
    ret = min(ret, tr[a]);
    a -= low(a);
  }
  return ret;
}
void ins(int a, int b) {
  while (a <= n + 5) {
    tr[a] = min(tr[a], b);
    a += low(a);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &E[i].a);
  for (int i = 0; i < n; i++) scanf("%d", &E[i].b);
  for (int i = 0; i < n; i++) scanf("%d", &E[i].c);
  for (int i = 0; i < n; i++) {
    E[i].a = -E[i].a;
    E[i].b = -E[i].b;
    E[i].c = -E[i].c;
    x[i] = E[i].b;
  }
  sort(x, x + n);
  m = unique(x, x + n) - x;
  for (int i = 0; i < n; i++) E[i].b = (lower_bound(x, x + m, E[i].b) - x) + 1;
  sort(E, E + n, cmp);
  for (int i = 0; i <= n + 5; i++) tr[i] = 1992837465;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int h = i;
    while (i < n && E[i].a == E[h].a) {
      if (ask(E[i].b - 1) < E[i].c) {
        ans++;
      }
      i++;
    }
    i--;
    for (int j = h; j <= i; j++) ins(E[j].b, E[j].c);
  }
  printf("%d\n", ans);
}
