#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
long long n, cnt, ans;
map<long long, long long> mp;
vector<long long> v1;
vector<pair<long long, long long> > v2;
pair<pair<long long, long long>, long long> a[N];
long long tree[4 * N];
void update(int node, int le, int ri, int idx, long long val) {
  if (le > idx || ri < idx) return;
  if (le == ri) {
    tree[node] = max(tree[node], val);
    return;
  }
  int mid = (le + ri) / 2;
  update(2 * node, le, mid, idx, val);
  update(2 * node + 1, mid + 1, ri, idx, val);
  tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
long long getans(int node, int le, int ri, int start, int end) {
  if (le > end || ri < start) return 0;
  if (le >= start && ri <= end) {
    return tree[node];
  }
  int mid = (le + ri) / 2;
  return max(getans(2 * node, le, mid, start, end),
             getans(2 * node + 1, mid + 1, ri, start, end));
}
int main() {
  std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first.first;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first.second;
    v1.push_back(a[i].first.second);
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second;
  }
  sort(v1.begin(), v1.end());
  mp[v1[0]] = 1;
  cnt = 1;
  for (int i = 1; i < v1.size(); i++) {
    if (v1[i] != v1[i - 1]) cnt++, mp[v1[i]] = cnt;
  }
  for (int i = 1; i <= n; i++) {
    a[i].first.second = mp[a[i].first.second];
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (getans(1, 1, N, a[i].first.second + 1, N) > a[i].second) {
      ans++;
    }
    if (a[i].first.first != a[i + 1].first.first) {
      v2.push_back({a[i].first.second, a[i].second});
      for (int i = 0; i < v2.size(); i++) {
        update(1, 1, N, v2[i].first, v2[i].second);
      }
      v2.clear();
    } else
      v2.push_back({a[i].first.second, a[i].second});
  }
  cout << ans << " ";
}
