#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 20;
long long n, sg[4 * maxn], ans, b[maxn], r[maxn], c[maxn];
vector<pair<pair<int, int>, int>> vec;
vector<int> vecr;
map<int, int> mp;
long long get(int s, int e, int l = 0, int r = n, int id = 1) {
  if (l >= s && r <= e) return sg[id];
  if (r <= s || l >= e) return 0;
  int mid = (l + r) / 2;
  return max(get(s, e, l, mid, id * 2), get(s, e, mid, r, id * 2 + 1));
}
void update(int ind, long long val, int l = 0, int r = n, int id = 1) {
  if (r - l == 1) {
    sg[id] = max(sg[id], val);
    return;
  }
  int mid = (l + r) / 2;
  ind < mid ? update(ind, val, l, mid, id * 2)
            : update(ind, val, mid, r, id * 2 + 1);
  sg[id] = max(sg[id * 2], sg[id * 2 + 1]);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> r[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    vec.push_back({{b[i], -r[i]}, c[i]});
    vecr.push_back(r[i]);
  }
  sort(vec.begin(), vec.end());
  sort(vecr.begin(), vecr.end());
  for (int i = 0; i < n; i++) mp[vecr[i]] = i;
  for (int i = n - 1; i >= 0; i--) {
    int tmp1 = get(mp[-vec[i].first.second] + 1, n);
    if (tmp1 > vec[i].second) ans++;
    update(mp[-vec[i].first.second], vec[i].second);
  }
  cout << ans << endl;
  return 0;
}
