#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, z;
};
node p[500010];
int tt[500010];
int r[500100], bb[500010];
bool cmpx(const node &a, const node &b) { return a.x > b.x; }
bool cmpy(int a, int b) { return p[a].y > p[b].y; }
int read(int x) {
  int ans = 0;
  while (x > 0) {
    ans = max(ans, tt[x]);
    x -= x & -x;
  }
  return ans;
}
void update(int x, int val) {
  int ans = 0;
  while (x <= 500005) {
    tt[x] = max(tt[x], val);
    x += x & -x;
  }
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) scanf("%d", &p[i].x);
    for (int i = 0; i < n; i++) scanf("%d", &p[i].y);
    for (int i = 0; i < n; i++) scanf("%d", &p[i].z);
    sort(p, p + n, cmpx);
    for (int i = 0; i < n; i++) r[i] = i;
    sort(r, r + n, cmpy);
    int now = 1;
    for (int i = 0; i < n; i++) {
      if (i == 0 || (p[r[i]].y != p[r[i - 1]].y)) now++;
      bb[r[i]] = now;
    }
    for (int i = 0; i < n; i++) p[i].y = bb[i];
    int total = 0;
    memset(tt, 0, sizeof(tt));
    for (int i = 0; i < n; i++) {
      int j;
      for (j = i; j < n && p[i].x == p[j].x; j++) {
        int num = read(p[j].y - 1);
        if (num > p[j].z) total++;
      }
      for (j = i; j < n && p[i].x == p[j].x; j++) update(p[j].y, p[j].z);
      j--;
      i = j;
    }
    printf("%d\n", total);
  }
  return 0;
}
