#include <bits/stdc++.h>
using namespace std;
const int mx = 500010;
typedef int elem;
struct RMQ {
  int **rec;
  elem *org;
  int n, h, len[20];
  void init(int n, elem *o, int b2(int a, int b));
  int (*better)(int a, int b);
  int rmq(int l, int r);
  void chg(elem va, int k);
} maxrmq, minrmq;
inline int better1(int a, int b) {
  return maxrmq.org[a] > maxrmq.org[b] ? a : b;
}
inline int better2(int a, int b) {
  return minrmq.org[a] < minrmq.org[b] ? a : b;
}
void RMQ::init(int len1, elem *o, int b2(int a, int b)) {
  h = 0;
  len[0] = n = len1;
  int i, j, p = n;
  while (p) {
    p /= 2;
    h++;
  }
  p = n;
  rec = (int **)malloc(sizeof(int *) * h);
  org = o;
  better = b2;
  rec[0] = (int *)malloc(sizeof(int) * (p + 1));
  for (j = 1; j <= n; j++) rec[0][j] = j;
  for (i = 1; i < h; i++) {
    p /= 2;
    rec[i] = (int *)malloc(sizeof(int) * (p + 1));
    len[i] = p;
    for (j = 1; j <= p; j++) {
      rec[i][j] = (*better)(rec[i - 1][j * 2], rec[i - 1][j * 2 - 1]);
    }
  }
}
void RMQ::chg(elem va, int k) {
  org[k] = va;
  for (int i = 1; i < h; i++) {
    k = (k + 1) / 2;
    if (k > len[i]) break;
    rec[i][k] = (*better)(rec[i - 1][k * 2], rec[i - 1][k * 2 - 1]);
  }
}
int RMQ::rmq(int l, int r) {
  int ans = l;
  r++;
  while (l < r) {
    int p = 0, q = 1, c = l - 1;
    while (!(c % q) && l + q <= r) p++, q <<= 1;
    p--, q >>= 1;
    ans = better(ans, rec[p][c / q + 1]);
    l += q;
  }
  return ans;
}
elem org[mx];
int n;
int a[mx], b[mx], c[mx], id[mx], pp = 0;
bool cmp(int p, int q) {
  if (b[p] != b[q]) return b[p] > b[q];
  return p < q;
}
bool cmp2(int p, int q) {
  if (a[p] != a[q]) return a[p] > a[q];
  if (b[p] != b[q]) return b[p] > b[q];
  if (c[p] != c[q]) return c[p] > c[q];
  return p < q;
}
RMQ mrmq;
bool check(int p) {
  if (b[p] + 1 > n) return true;
  int q = mrmq.rmq(b[p] + 1, n);
  if (c[p] >= mrmq.org[q]) return true;
  return false;
}
void add(int p) {
  if (c[p] > mrmq.org[b[p]]) mrmq.chg(c[p], b[p]);
}
int better0(int a, int b) { return mrmq.org[a] > mrmq.org[b] ? a : b; }
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  int cc = n;
  pp = 1;
  while (pp <= n) {
    for (j = pp; j <= n; j++) {
      if (b[id[j]] != b[id[pp]]) break;
    }
    for (i = pp; i < j; i++) b[id[i]] = cc;
    cc--;
    pp = j;
  }
  for (i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, cmp2);
  for (i = 1; i <= n; i++) {
    int ee = id[i];
  }
  cc = 1;
  int ans = 0;
  for (int ss = 1; ss <= n; ss++) org[ss] = -1;
  mrmq.init(n, org, better0);
  while (cc <= n) {
    for (j = cc; j <= n; j++) {
      if (a[id[j]] != a[id[cc]]) break;
    }
    for (i = cc; i < j; i++) {
      if (!check(id[i])) {
        ans++;
      }
    }
    for (i = cc; i < j; i++) add(id[i]);
    cc = j;
  }
  printf("%d\n", ans);
  return 0;
}
