#include <bits/stdc++.h>
using namespace std;
struct trip {
  int a, b, c;
  static bool cmp_c(const trip& me, const trip& other) {
    return me.c > other.c;
  }
};
int n;
trip ts[500005];
map<int, int> m;
int query(int b) {
  map<int, int>::iterator it = m.upper_bound(b);
  return it->second;
}
void add(int b, int v) {
  map<int, int>::iterator it = m.upper_bound(b);
  if (v <= it->second) return;
  if (it->first > b) it--;
  vector<int> torem;
  while (it->second <= v) {
    torem.push_back(it->first);
    it--;
  }
  for (int i = 0; i < (int)torem.size(); i++) m.erase(torem[i]);
  if (m.find(b) == m.end() || m[b] < v) m[b] = v;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &ts[i].a);
  for (int i = 0; i < n; i++) scanf("%d", &ts[i].b);
  for (int i = 0; i < n; i++) scanf("%d", &ts[i].c);
  sort(ts, ts + n, trip::cmp_c);
  m[-1] = 1e9 + 5;
  m[1e9 + 5] = -1;
  int ans = 0;
  for (int from = 0; from < n;) {
    int to = from + 1;
    while (to < n && ts[to].c == ts[from].c) to++;
    for (int i = from; i < to; i++) ans += query(ts[i].a) > ts[i].b;
    for (int i = from; i < to; i++) add(ts[i].a, ts[i].b);
    from = to;
  }
  printf("%d\n", ans);
  return 0;
}
