#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline string getStr() {
  char str[1000000];
  scanf("%s", str);
  return str;
}
inline char getCh() {
  char ch;
  scanf(" %c", &ch);
  return ch;
}
template <class P, class Q>
inline P smin(P &a, Q b) {
  if (b < a) a = b;
  return a;
}
template <class P, class Q>
inline P smax(P &a, Q b) {
  if (a < b) a = b;
  return a;
}
const long long MAX_N = 5e5 + 10;
long long fn[MAX_N];
pair<long long, long long> a[MAX_N];
long long b[2][MAX_N], c[MAX_N];
inline long long get(long long v) {
  long long ret = 0;
  for (; v; v -= v & -v) smax(ret, fn[v]);
  return ret;
}
inline void update(long long v, long long val) {
  for (; v < MAX_N; v += v & -v) smax(fn[v], val);
}
map<long long, long long> Mp;
long long pt;
long long res;
int32_t main() {
  long long n = in();
  for (long long i = 0; i < n; i++) {
    a[i].first = in(), a[i].second = i;
  }
  for (long long i = 0; i < n; i++) b[0][i] = in(), b[1][i] = b[0][i];
  for (long long i = 0; i < n; i++) c[i] = in();
  sort(a, a + n);
  sort(b[1], b[1] + n, greater<long long>());
  for (long long i = 0; i < n; i++)
    if (!Mp[b[1][i]]) Mp[b[1][i]] = ++pt;
  for (long long i = n - 1; i >= 0; i--) {
    long long gt = get(Mp[b[0][a[i].second]] - 1);
    if (gt > c[a[i].second]) res++;
    if (!i) break;
    if (a[i].first != a[i - 1].first)
      for (long long j = i; j < n && a[j].first == a[i].first; j++)
        update(Mp[b[0][a[j].second]], c[a[j].second]);
  }
  cout << res << endl;
}
