#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
void read() {}
void say() {}
void say_() {}
template <typename T, typename... T2>
inline void read(T &_, T2 &...oth) {
  int __ = 0;
  _ = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') __ = 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    _ = _ * 10 + ch - 48;
    ch = getchar();
  }
  _ = __ ? -_ : _;
  read(oth...);
}
template <typename T>
void Out(T _) {
  if (_ < 0) {
    putchar('-');
    _ = -_;
  }
  if (_ >= 10) Out(_ / 10);
  putchar(_ % 10 + '0');
}
template <typename T, typename... T2>
inline void say(T _, T2... oth) {
  Out(_);
  putchar('\n');
  say(oth...);
}
template <typename T, typename... T2>
inline void say_(T _, T2... oth) {
  Out(_);
  putchar(' ');
  say_(oth...);
}
const int N = 5E5 + 10;
int n, m, ans;
int t[N], vx[N], vy[N], vz[N];
struct Node {
  int x, y, z, die;
  void pt() {
    say_(x, y, z, die);
    puts("");
  }
} a[N];
void add(int x, int val) {
  while (x <= m) {
    t[x] += val;
    x += x & -x;
  }
}
int query(int x) {
  int ret = 0;
  while (x) {
    ret += t[x];
    x -= x & -x;
  }
  return ret;
}
void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  sort(a + l, a + mid + 1, [](const Node &u, const Node &v) {
    if (u.y == v.y) return u.z > v.z;
    return u.y > v.y;
  });
  sort(a + mid + 1, a + r + 1, [](const Node &u, const Node &v) {
    if (u.y == v.y) return u.z > v.z;
    return u.y > v.y;
  });
  int ind = l;
  for (int i = mid + 1; i <= r; ++i) {
    while (ind <= mid && a[ind].y > a[i].y) {
      add(a[ind].z, 1);
      ++ind;
    }
    a[i].die += query(m) - query(a[i].z);
  }
  for (int i = l; i <= ind - 1; ++i) add(a[i].z, -1);
}
void print() {}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i].x);
    vx[i] = a[i].x;
  }
  for (int i = 1; i <= n; ++i) {
    read(a[i].y);
    vy[i] = a[i].y;
  }
  for (int i = 1; i <= n; ++i) {
    read(a[i].z);
    vz[i] = a[i].z;
  }
  sort(vx + 1, vx + n + 1);
  int nx = unique(vx + 1, vx + n + 1) - vx - 1;
  sort(vy + 1, vy + n + 1);
  int ny = unique(vy + 1, vy + n + 1) - vy - 1;
  sort(vz + 1, vz + n + 1);
  int nz = unique(vz + 1, vz + n + 1) - vz - 1;
  m = nz;
  for (int i = 1; i <= n; ++i) {
    a[i].x = lower_bound(vx + 1, vx + nx + 1, a[i].x) - vx;
    a[i].y = lower_bound(vy + 1, vy + ny + 1, a[i].y) - vy;
    a[i].z = lower_bound(vz + 1, vz + nz + 1, a[i].z) - vz;
  }
  sort(a + 1, a + n + 1, [](const Node &u, const Node &v) {
    if (u.x == v.x) {
      if (u.y == v.y) return u.z > v.z;
      return u.y > v.y;
    }
    return u.x > v.x;
  });
  int l = 1, r = 0;
  while (l <= n) {
    while (r < n && a[r + 1].x == a[l].x) ++r;
    for (int i = l; i <= r; ++i) {
      int ind = i;
      while (ind < r && a[i].y == a[ind + 1].y) ++ind;
      for (int j = i; j <= ind; ++j) a[j].die -= query(m) - query(a[j].z);
      for (int j = i; j <= ind; ++j) add(a[j].z, 1);
      i = ind;
    }
    for (int i = l; i <= r; ++i) add(a[i].z, -1);
    l = r + 1;
  }
  cdq(1, n);
  for (int i = 1; i <= n; ++i) ans += a[i].die > 0 ? 1 : 0;
  say(ans);
}
