#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int B[maxn], I[maxn], R[maxn];
int ind[maxn];
int seg[maxn * 4];
void add(int l, int r, int ind, int val, int x) {
  if (l + 1 >= r) {
    seg[x] = val;
    return;
  }
  int mid = (l + r) / 2;
  if (ind < mid)
    add(l, mid, ind, val, x * 2);
  else
    add(mid, r, ind, val, x * 2 + 1);
  seg[x] = max(seg[x * 2], seg[x * 2 + 1]);
}
int get(int l, int r, int L, int R, int x) {
  if (l >= R || r <= L) return -1;
  if (l >= L && r <= R) return seg[x];
  int mid = (l + r) / 2;
  return max(get(l, mid, L, R, x * 2), get(mid, r, L, R, x * 2 + 1));
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return true;
  if (b.first > a.first)
    return false;
  else {
    if (I[a.second] < I[b.second])
      return true;
    else if (I[b.second] < I[a.second])
      return false;
    else {
      if (R[a.second] < R[b.second])
        return true;
      else
        return false;
    }
  }
}
bool cmp2(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else if (b.first > a.first)
    return false;
  else {
    if (R[a.second] < R[b.second])
      return true;
    else
      return false;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<pair<int, int> > vec, vec2;
  for (int i = 0; i < n; i++) {
    cin >> B[i];
    vec.push_back({B[i], i});
  }
  for (int i = 0; i < n; i++) cin >> I[i];
  for (int i = 0; i < n; i++) cin >> R[i];
  sort(vec.begin(), vec.end(), cmp);
  int c = 0;
  for (auto u : vec) {
    ind[c] = u.second;
    vec2.push_back({I[u.second], c});
    c++;
  }
  sort(vec2.begin(), vec2.end(), cmp2);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int v = vec2[i].first;
    int j = i;
    while (j < n && vec2[j].first == v) {
      int x = vec2[j].second;
      int val = R[ind[x]];
      int mx = get(0, n, 0, x, 1);
      if (mx > val) cnt++;
      j++;
    }
    for (int k = i; k < j; k++) {
      int x = vec2[k].second;
      int val = R[ind[x]];
      add(0, n, x, val, 1);
    }
    i = j - 1;
  }
  cout << cnt;
  return 0;
}
