#include <bits/stdc++.h>
using namespace std;
void solutionD();
int main() {
  ios_base::sync_with_stdio(false);
  solutionD();
  return EXIT_SUCCESS;
}
int n;
struct lady {
  int a, b, c;
} p[1000000];
int t[1000000 * 10];
bool test = false;
bool operator<(const lady& x, const lady& y) {
  if (x.a != y.a) return x.a < y.a;
  if (x.b != y.b) return x.b < y.b;
  return x.c < y.c;
}
void error(bool cond, string msg) {
  if (cond) return;
  cout << "ERROR: " << msg << endl;
  exit(0);
}
void build(int v, int tl, int tr) {
  if (tl >= tr) return;
  if (tl + 1 == tr) {
    t[v] = -1;
    return;
  }
  int mid = (tl + tr) / 2;
  build((v << 1), tl, mid);
  build((v << 1) | 1, mid, tr);
  t[v] = max(t[(v << 1)], t[(v << 1) | 1]);
}
void update(int v, int tl, int tr, int ql, int qr, int y) {
  if (tl >= tr || ql >= qr) return;
  if (tl == ql && tr == qr) {
    if (t[v] < y) t[v] = y;
    return;
  }
  int mid = (tl + tr) / 2;
  update((v << 1), tl, mid, ql, min(qr, mid), y);
  update((v << 1) | 1, mid, tr, max(mid, ql), qr, y);
  t[v] = max(t[(v << 1)], t[(v << 1) | 1]);
}
int get(int v, int tl, int tr, int ql, int qr) {
  if (tl >= tr || ql >= qr) return -2;
  if (tl == ql && tr == qr) return t[v];
  int mid = (tl + tr) / 2;
  return max(get((v << 1), tl, mid, ql, min(mid, qr)),
             get((v << 1) | 1, mid, tr, max(mid, ql), qr));
}
void solve() {
  sort(p, p + n);
  vector<int> cv;
  for (int i = 0; i < n; ++i) {
    cv.push_back(p[i].b);
    cv.push_back(p[i].c);
  }
  sort(cv.begin(), cv.end());
  int cc = unique(cv.begin(), cv.end()) - cv.begin();
  cv.resize(cc);
  for (int i = 0; i < n; ++i) {
    p[i].b = lower_bound(cv.begin(), cv.end(), p[i].b) - cv.begin();
    p[i].c = lower_bound(cv.begin(), cv.end(), p[i].c) - cv.begin();
  }
  int m = cc;
  build(1, 0, m);
  int res = 0;
  for (int i = n - 1; i >= 0;) {
    int j = i;
    while (j >= 0 && p[j].a == p[i].a) --j;
    for (int k = i; k > j; --k) {
      int mx = get(1, 0, m, p[k].b + 1, m);
      if (mx > p[k].c) ++res;
    }
    for (int k = i; k > j; --k) update(1, 0, m, p[k].b, p[k].b + 1, p[k].c);
    i = j;
  }
  cout << res << endl;
}
void solutionD() {
  for (; cin >> n;) {
    for (int i = 0; i < n; ++i) cin >> p[i].a;
    for (int i = 0; i < n; ++i) cin >> p[i].b;
    for (int i = 0; i < n; ++i) cin >> p[i].c;
    solve();
    cerr << endl;
  }
}
