#include <bits/stdc++.h>
using namespace std;
map<int, int> ytailMax;
int segmentsMax[500001 * 4 + 1];
int yCount = 0;
int getMax(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return segmentsMax[v];
  int tm = (tl + tr) / 2;
  int maxLeft = getMax(v * 2, tl, tm, l, min(r, tm));
  int maxRight = getMax(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
  return max(maxLeft, maxRight);
}
void update(int v, int tl, int tr, int pos, int new_val) {
  if (tl == tr) {
    segmentsMax[v] = max(segmentsMax[v], new_val);
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    update(v * 2, tl, tm, pos, new_val);
  else
    update(v * 2 + 1, tm + 1, tr, pos, new_val);
  segmentsMax[v] = max(segmentsMax[v * 2], segmentsMax[v * 2 + 1]);
}
bool exists(int y, int z) { return getMax(1, 1, 500001, y + 1, 500001) > z; }
void insert(int y, int z) { update(1, 1, 500001, y, z); }
int main() {
  int x[500001];
  int y[500001];
  int z[500001];
  map<int, vector<pair<int, int> > > xp;
  int n;
  cin >> n;
  for (__typeof(n) i = 0; i < n; i++) {
    scanf("%d", x + i);
    xp.insert(make_pair(x[i], vector<pair<int, int> >()));
  }
  for (__typeof(500001 * 4 + 1) i = 0; i < 500001 * 4 + 1; i++)
    segmentsMax[i] = 0;
  int yOriginal[n];
  for (__typeof(n) i = 0; i < n; i++) {
    scanf("%d", yOriginal + i);
    y[i] = yOriginal[i];
  }
  sort(yOriginal, yOriginal + n);
  int compactedYSize = yCount =
      int(unique(yOriginal, yOriginal + n) - yOriginal);
  int zOriginal[n];
  for (__typeof(n) i = 0; i < n; i++) {
    scanf("%d", zOriginal + i);
    z[i] = zOriginal[i];
  }
  sort(zOriginal, zOriginal + n);
  int compactedZSize = int(unique(zOriginal, zOriginal + n) - zOriginal);
  for (__typeof(n) i = 0; i < n; i++) {
    int compactY =
        upper_bound(yOriginal, yOriginal + compactedYSize, y[i]) - yOriginal;
    int compactZ =
        upper_bound(zOriginal, zOriginal + compactedZSize, z[i]) - zOriginal;
    xp[x[i]].push_back(make_pair(compactY, compactZ));
  }
  int sum = 0;
  for (__typeof((xp).rbegin()) it = (xp).rbegin(); it != (xp).rend(); it++) {
    for (__typeof((it->second).begin()) jt = (it->second).begin();
         jt != (it->second).end(); jt++)
      if (exists(jt->first, jt->second)) sum++;
    for (__typeof((it->second).begin()) jt = (it->second).begin();
         jt != (it->second).end(); jt++)
      insert(jt->first, jt->second);
  }
  cout << sum;
}
