#include <bits/stdc++.h>
using namespace std;
int gid;
struct PH {
  int x, y, z;
  int pos;
  bool operator<(const PH &h) const { return x > h.x; }
} ph[500003], p[500003];
bool cmp(PH a, PH b) { return a.y < b.y; }
struct Tree {
  int left, right, mid, val;
} tree[2500001];
void build(int id, int l, int r) {
  tree[id].left = l;
  tree[id].right = r;
  tree[id].val = -1;
  tree[id].mid = (l + r) >> 1;
  if (l == r) return;
  build(id * 2, l, tree[id].mid);
  build(id * 2 + 1, tree[id].mid + 1, r);
}
int query(int id, int l, int r) {
  if (l == tree[id].left && r == tree[id].right) {
    return tree[id].val;
  }
  if (r <= tree[id].mid)
    return query(id * 2, l, r);
  else if (l > tree[id].mid)
    return query(id * 2 + 1, l, r);
  return max(query(id * 2, l, tree[id].mid),
             query(id * 2 + 1, tree[id].mid + 1, r));
}
void update(int id, int pos, int val) {
  if (tree[id].left == tree[id].right) {
    tree[id].val = max(tree[id].val, val);
    return;
  }
  if (pos <= tree[id].mid)
    update(id * 2, pos, val);
  else if (pos > tree[id].mid)
    update(id * 2 + 1, pos, val);
  tree[id].val = max(tree[id * 2].val, tree[id * 2 + 1].val);
}
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &ph[i].x);
  for (i = 0; i < n; i++) scanf("%d", &ph[i].y);
  for (i = 0; i < n; i++) scanf("%d", &ph[i].z);
  sort(ph, ph + n);
  gid = 1;
  for (i = 0; i < n; i++) {
    ph[i].pos = i;
    p[i] = ph[i];
  }
  sort(p, p + n, cmp);
  ph[p[0].pos].y = gid;
  for (i = 1; i < n; i++) {
    if (p[i].y != p[i - 1].y) gid++;
    ph[p[i].pos].y = gid;
  }
  build(1, 1, gid + 1);
  int ans = 0;
  int mark = ph[0].x;
  for (i = 0; i < n;) {
    for (j = i; j < n; j++) {
      if (ph[j].x == mark) {
        int y = ph[j].y;
        if (y < gid && query(1, y + 1, gid) > ph[j].z) ans++;
      } else {
        mark = ph[j].x;
        break;
      }
    }
    for (; i < j; i++) {
      update(1, ph[i].y, ph[i].z);
    }
  }
  printf("%d\n", ans);
  return 0;
}
