#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = getchar(), f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
const int N = 500000 + 10;
struct node {
  int a, b, c;
  bool operator<(const node &B) const { return a > B.a; }
} p[N];
int n, h[N], ans, L, R, V;
struct seg {
  int mx, lazy;
} T[N * 4];
int dic(int x) {
  for (int l = 1, r = *h, mid; l <= r;)
    if (h[mid = (l + r) >> 1] == x)
      return mid;
    else if (h[mid] > x)
      r = mid - 1;
    else
      l = mid + 1;
}
void down(int o) {
  int &x = T[o].lazy;
  if (x) {
    T[o << 1].lazy = max(T[o << 1].lazy, x);
    T[o << 1 | 1].lazy = max(T[o << 1 | 1].lazy, x);
    T[o << 1].mx = max(T[o << 1].mx, x);
    T[o << 1 | 1].mx = max(T[o << 1 | 1].mx, x);
    x = -1;
  }
}
int query(int o, int l, int r) {
  if (L > R) return 0;
  if (L <= l && R >= r) return T[o].mx;
  int mid = (l + r) >> 1, res = 0;
  down(o);
  if (L <= mid) res = query(o << 1, l, mid);
  if (R > mid) res = max(res, query(o << 1 | 1, mid + 1, r));
  return res;
}
void modify(int o, int l, int r) {
  if (L <= l && R >= r) {
    T[o].lazy = max(T[o].lazy, V);
    T[o].mx = max(T[o].mx, V);
    return;
  }
  int mid = (l + r) >> 1;
  down(o);
  if (L <= mid) modify(o << 1, l, mid);
  if (R > mid) modify(o << 1 | 1, mid + 1, r);
  T[o].mx = max(T[o << 1].mx, T[o << 1 | 1].mx);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) p[i].a = read();
  for (int i = 1; i <= n; i++) h[++*h] = p[i].b = read();
  for (int i = 1; i <= n; i++) p[i].c = read();
  sort(h + 1, h + *h + 1);
  *h = unique(h + 1, h + *h + 1) - (h + 1);
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    int j = i;
    for (; j < n && p[i].a == p[j + 1].a; j++)
      ;
    for (int k = i; k <= j; k++) {
      L = (p[k].b = dic(p[k].b)) + 1;
      R = *h;
      int c = query(1, 1, *h);
      if (c > p[k].c) ans++;
    }
    for (int k = i; k <= j; k++)
      V = p[k].c, L = 1, R = p[k].b, modify(1, 1, *h);
    i = j;
  }
  printf("%d\n", ans);
}
