#include <bits/stdc++.h>
using namespace std;
const int MXN = (int)5e5 + 3;
int BitZ[MXN], N, MXY;
struct node {
  int x, y, z;
} A[MXN];
int dy[MXN];
bool compXr(const node& a, const node& b) { return a.x > b.x; }
int getMaxZ(int y) {
  int r = -1;
  for (; y > 0; y -= y & -y) r = max(r, BitZ[y]);
  return r;
}
void updateMaxZ(int y, int v) {
  for (; y <= MXY; y += y & -y) BitZ[y] = max(v, BitZ[y]);
}
int main() {
  int i, j, k, a, b, c, r = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i].x);
  for (i = 0; i < N; i++) scanf("%d", &A[i].y);
  for (i = 0; i < N; i++) scanf("%d", &A[i].z);
  for (i = 0; i < N; i++) dy[i] = A[i].y;
  sort(dy, dy + N);
  MXY = unique(dy, dy + N) - dy;
  for (i = 0; i < N; i++)
    A[i].y = MXY - (lower_bound(dy, dy + MXY, A[i].y) - dy);
  sort(A, A + N, compXr);
  memset(BitZ, -1, sizeof BitZ);
  for (i = 0; i < N;) {
    for (j = i; j < N; j++) {
      if (A[j].x != A[i].x) break;
      if (A[j].z < getMaxZ(A[j].y - 1)) r++;
    }
    for (; i < j; i++) {
      updateMaxZ(A[i].y, A[i].z);
    }
  }
  printf("%d\n", r);
  return 0;
}
