#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int arr = 2e5 + 10;
const int ar = 2e3 + 10;
const long double pi = acos(-1);
const long double eps = 1e-10;
const long long md = 1e9 + 7;
map<int, int> vh;
int cnt_vh;
void do_vh() {
  for (auto& i : vh) {
    i.second = cnt_vh++;
  }
}
int f[(int)(2e6 + 10)];
void upd(int pos, int val) {
  for (int i = pos; i < (int)(2e6 + 10); i |= i + 1) {
    f[i] = max(f[i], val);
  }
}
int get(int pos) {
  int res = 0;
  for (int i = pos; i >= 0; i &= i + 1, i--) {
    res = max(res, f[i]);
  }
  return res;
}
int a[(int)(2e6 + 10)];
int b[(int)(2e6 + 10)];
int c[(int)(2e6 + 10)];
int vals[(int)(2e6 + 10)];
const bool cmp(const int& lhs, const int& rhs) { return a[lhs] > a[rhs]; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    vh[a[i]];
    vh[b[i]];
    vh[c[i]];
    vals[i] = i;
  }
  do_vh();
  for (int i = 0; i < n; i++) {
    a[i] = vh[a[i]];
    b[i] = vh[b[i]];
    c[i] = vh[c[i]];
  }
  sort(vals, vals + n, cmp);
  int ans = 0;
  for (int i = 0; i < n;) {
    int j = i;
    while (j < n && a[vals[i]] == a[vals[j]]) {
      j++;
    }
    for (int k = i; k < j; k++) {
      int A = a[vals[k]];
      int B = b[vals[k]];
      int C = c[vals[k]];
      if (get((int)(2e6 + 10) - (B + 1)) > C) {
        ans++;
      }
    }
    for (int k = i; k < j; k++) {
      int A = a[vals[k]];
      int B = b[vals[k]];
      int C = c[vals[k]];
      upd((int)(2e6 + 10) - B, C);
    }
    i = j;
  }
  cout << ans << "\n";
}
