#include <bits/stdc++.h>
using namespace std;
const int SIZE = 5e5 + 5;
int n;
int tmp[SIZE];
struct lady {
  int a, b, c;
  bool operator<(const lady &t) const {
    return (a < t.a || (a == t.a && (b < t.b || (b == t.b) && c < t.c)));
  }
} a[SIZE];
struct node {
  int l, r, maxx;
} tree[SIZE << 2];
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int read() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::read;
void pushUp(int p) {
  tree[p].maxx = std::max(tree[p << 1].maxx, tree[p << 1 | 1].maxx);
}
void build(int p, int l, int r) {
  tree[p].l = l, tree[p].r = r;
  if (l == r) {
    tree[p].maxx = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushUp(p);
}
void modify(int p, int pos, int val) {
  if (tree[p].l == tree[p].r) {
    tree[p].maxx = std::max(tree[p].maxx, val);
    return;
  }
  int mid = (tree[p].l + tree[p].r) >> 1;
  if (pos <= mid)
    modify(p << 1, pos, val);
  else
    modify(p << 1 | 1, pos, val);
  pushUp(p);
}
int query(int p, int l, int r) {
  if (l <= tree[p].l && tree[p].r <= r) {
    return tree[p].maxx;
  }
  int mid = (tree[p].l + tree[p].r) >> 1, ans = 0;
  if (l <= mid) ans = std::max(ans, query(p << 1, l, r));
  if (r > mid) ans = std::max(ans, query(p << 1 | 1, l, r));
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i].a = read();
  for (int i = 1; i <= n; ++i) tmp[i] = a[i].b = read();
  for (int i = 1; i <= n; ++i) a[i].c = read();
  std::sort(tmp + 1, tmp + n + 1);
  int N = std::unique(tmp + 1, tmp + n + 1) - tmp - 1;
  for (int i = 1; i <= n; ++i) {
    a[i].b = lower_bound(tmp + 1, tmp + N + 1, a[i].b) - tmp;
  }
  std::sort(a + 1, a + n + 1);
  build(1, 1, N);
  int cnt = 0, j = n;
  for (int i = n; i; --i) {
    if (a[i].a != a[j].a) {
      while (j > i) modify(1, a[j].b, a[j].c), --j;
    }
    cnt += (query(1, a[i].b + 1, N) > a[i].c && a[i].b != N) ? 1 : 0;
  }
  printf("%d\n", cnt);
  return 0;
}
