#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e6 + 17;
int t[MaxN];
int n;
pair<int, pair<int, int> > p[MaxN];
int a[MaxN];
int szt(int x) {
  int y = lower_bound(a + 1, a + n + 1, x) - a;
  return y;
}
void rez() {
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) a[i] = p[i].first;
  for (int i = 1; i <= n; ++i) {
    a[i] = p[i].first;
    p[i].first = szt(p[i].first);
  }
}
void upd(int v, int l, int r, int pos, int val) {
  if (l == r) {
    t[v] = max(t[v], val);
  } else {
    int m = (l + r) >> 1;
    if (pos <= m)
      upd(v + v, l, m, pos, val);
    else
      upd(v + v + 1, m + 1, r, pos, val);
    t[v] = max(t[v + v], t[v + v + 1]);
  }
}
int Get(int v, int l, int r, int L, int R) {
  if (l > R || r < L) return 0;
  if (L <= l && r <= R) return t[v];
  int m = (l + r) >> 1;
  return max(Get(v + v, l, m, L, R), Get(v + v + 1, m + 1, r, L, R));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i].first), p[i].first++;
  for (int i = 1; i <= n; ++i)
    scanf("%d", &p[i].second.first), p[i].second.first++;
  for (int i = 1; i <= n; ++i)
    scanf("%d", &p[i].second.second), p[i].second.second++;
  rez();
  for (int i = 1; i <= n; ++i) swap(p[i].first, p[i].second.first);
  rez();
  for (int i = 1; i <= n; ++i) swap(p[i].first, p[i].second.second);
  rez();
  int Sum = 0;
  reverse(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) {
    int j = i + 1;
    while (j <= n && p[i].first == p[j].first) ++j;
    for (int k = i; k < j; ++k) {
      int x = p[k].second.first;
      int y = p[k].second.second;
      int z = Get(1, 1, n, x + 1, n);
      if (z > y) Sum++;
    }
    for (int k = i; k < j; ++k) {
      int x = p[k].second.first;
      int y = p[k].second.second;
      upd(1, 1, n, x, y);
    }
    i = j - 1;
  }
  cout << Sum;
  return 0;
}
