#include <bits/stdc++.h>
using namespace std;
struct lady {
  int b, i, r;
  bool operator<(const lady &a) const { return a.b < b; }
} l[500100];
int ST[500100 * 4];
vector<int> values;
map<int, int> mapa;
int Query(int idx, int l, int r, int left, int right) {
  if (l <= left && right <= r) return ST[idx];
  int ret = 0;
  if (l <= (left + right) / 2)
    ret = max(ret, Query(2 * idx, l, r, left, (left + right) / 2));
  if (r > (left + right) / 2)
    ret = max(ret, Query(2 * idx + 1, l, r, (left + right) / 2 + 1, right));
  return ret;
}
void Update(int idx, int pos, int val, int left, int right) {
  if (left == right) {
    ST[idx] = max(ST[idx], val);
    return;
  }
  if (pos <= (left + right) / 2)
    Update(2 * idx, pos, val, left, (left + right) / 2);
  if (pos > (left + right) / 2)
    Update(2 * idx + 1, pos, val, (left + right) / 2 + 1, right);
  ST[idx] = max(ST[2 * idx], ST[2 * idx + 1]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &l[i].b);
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i].i);
    values.push_back(l[i].i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &l[i].r);
  sort(values.begin(), values.end());
  for (int i = 0; i < values.size(); i++) mapa[values[i]] = i + 1;
  sort(l, l + n);
  int sol = 0;
  int idx = 0;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    if (i > 0 && l[i].b != l[i - 1].b) {
      while (!q.empty()) {
        int idx = q.front();
        q.pop();
        Update(1, mapa[l[idx].i], l[idx].r, 1, 500010);
      }
    }
    int maks = Query(1, mapa[l[i].i] + 1, 500010, 1, 500010);
    if (maks > l[i].r) sol++;
    q.push(i);
  }
  printf("%d\n", sol);
  return 0;
}
