#include <bits/stdc++.h>
using namespace std;
int tree[4 * 500005], cnt[500005];
pair<int, pair<int, int> > p[500005];
void build_tree(int node, int a, int b) {
  if (a > b) return;
  if (a == b) {
    tree[node] = p[a].second.second;
    return;
  }
  build_tree(2 * node + 1, a, (a + b) / 2);
  build_tree(2 * node + 2, (a + b) / 2 + 1, b);
  tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
}
void update_tree(int node, int a, int b, int i, int j, int value) {
  if (a > b || a > j || b < i) return;
  if (a >= i && b <= j) {
    tree[node] = value;
    return;
  }
  update_tree(2 * node + 1, a, (a + b) / 2, i, j, value);
  update_tree(2 * node + 2, (a + b) / 2 + 1, b, i, j, value);
  tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
}
int query(int node, int a, int b, int i, int j) {
  if (a > b || a > j || b < i) return -1000000000;
  if (a >= i && b <= j) return tree[node];
  int c = query(2 * node + 1, a, (a + b) / 2, i, j);
  int d = query(2 * node + 2, (a + b) / 2 + 1, b, i, j);
  return max(c, d);
}
int main() {
  int n, a, ans = 0, b;
  scanf("%d", &n);
  vector<int> pos, vec;
  multiset<int> Set;
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i].first);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i].second.first);
    pos.push_back(p[i].second.first);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i].second.second);
  }
  sort(p, p + n);
  sort(pos.begin(), pos.end());
  for (int i = 0; i < n; i++) {
    a = (int)(lower_bound(pos.begin(), pos.end(), p[i].second.first) -
              pos.begin());
    vec.push_back(p[i].second.first);
    p[i].second.first = a + cnt[a]++;
    update_tree(0, 0, n - 1, p[i].second.first, p[i].second.first,
                p[i].second.second);
    Set.insert(vec[i]);
  }
  for (int i = 0; i < n;) {
    int j = i;
    while (p[i].first == p[j].first) {
      update_tree(0, 0, n - 1, p[j].second.first, p[j].second.first, 0);
      Set.erase(Set.find(vec[j]));
      j++;
    }
    for (; i < j; i++) {
      if (Set.upper_bound(vec[i]) != Set.end()) {
        a = *Set.upper_bound(vec[i]);
        b = a;
        a = (int)(lower_bound(pos.begin(), pos.end(), a) - pos.begin());
        if (p[i].second.second < query(0, 0, n - 1, a, n - 1)) {
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
