#include <bits/stdc++.h>
using namespace std;
struct pp {
  int x, y, z;
} p[1000000];
bool cmpls(const pp &i, const pp &j) { return i.x < j.x; }
bool cmp(const pp &i, const pp &j) {
  return i.z > j.z || i.z == j.z && i.x < j.x;
}
struct tree {
  int l, r, v;
} t[4000000];
int td[1000000], n, id, wzit[1000000];
void build(int p, int x, int y) {
  t[p].l = x;
  t[p].r = y;
  t[p].v = -200000000;
  if (x != y) {
    build(p * 2, x, (x + y) / 2);
    build(p * 2 + 1, (x + y) / 2 + 1, y);
  } else
    wzit[x] = p;
}
int ask(int p, int x, int y) {
  if (t[p].l == x && t[p].r == y) return t[p].v;
  int mid = (t[p].l + t[p].r) / 2;
  if (y <= mid) return ask(p * 2, x, y);
  if (x > mid) return ask(p * 2 + 1, x, y);
  return max(ask(p * 2, x, mid), ask(p * 2 + 1, mid + 1, y));
}
int main() {
  scanf("%d", &n);
  int ans = 0;
  build(1, 1, n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].x);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].y);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].z);
  sort(p + 1, p + n + 1, cmpls);
  int nowid = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || p[i].x != p[i - 1].x) id++;
    td[i] = id;
  }
  for (int i = 1; i <= n; i++) p[i].x = td[i];
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int wz = p[i].x;
    if (wz != n) {
      int maxv = ask(1, wz + 1, n);
      if (maxv > p[i].y) ans++;
    }
    for (int k = wzit[wz]; k; k = k >> 1) t[k].v = max(t[k].v, p[i].y);
  }
  printf("%d", ans);
}
