#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m[N], t[N];
struct People {
  int a, b, c, cnt;
} p[N], ran[N];
int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x;
}
bool cmp(People x, People y) {
  if (x.a != y.a)
    return x.a > y.a;
  else
    return x.c < y.c;
}
int lowbit(int x) { return x & -x; }
void add(int x, int k) {
  for (; x <= n; x += lowbit(x)) t[x] += k;
  return;
}
int sum(int x) {
  int ret = 0;
  for (; x; x -= lowbit(x)) ret += t[x];
  return ret;
}
void merge(int l, int r) {
  if (l == r) return;
  int mid = (l + r) / 2;
  merge(l, mid);
  merge(mid + 1, r);
  int i = l, j = mid + 1, cur = l;
  for (; i <= mid && j <= r;) {
    if (p[i].b > p[j].b)
      add(p[i].c, 1), ran[cur++] = p[i++];
    else
      p[j].cnt += sum(n) - sum(p[j].c), ran[cur++] = p[j++];
  }
  for (; i <= mid;) add(p[i].c, 1), ran[cur++] = p[i++];
  for (; j <= r;) p[j].cnt += sum(n) - sum(p[j].c), ran[cur++] = p[j++];
  for (i = l; i <= mid; ++i) add(p[i].c, -1);
  for (i = l; i <= r; ++i) p[i] = ran[i];
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) p[i].a = read();
  for (int i = 1; i <= n; ++i) p[i].b = read();
  for (int i = 1; i <= n; ++i) p[i].c = read(), m[i] = p[i].c;
  sort(m + 1, m + 1 + n);
  for (int i = 1; i <= n; ++i)
    p[i].c = lower_bound(m + 1, m + 1 + n, p[i].c) - m;
  sort(p + 1, p + 1 + n, cmp);
  merge(1, n);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (p[i].cnt) ++ans;
  printf("%d\n", ans);
  return 0;
}
