#include <bits/stdc++.h>
using namespace std;
int ans, tree[500005], u[500005], ret[500005], cnt;
bool retgood[500005];
map<int, int> m;
map<int, int>::iterator it;
struct ele {
  int x, y, z;
  bool operator==(const ele a) const {
    return x == a.x && y == a.y && z == a.z;
  }
} a[500005];
inline bool cmp(const ele &a, const ele &b) {
  return a.x != b.x ? a.x < b.x : a.y != b.y ? a.y > b.y : a.z < b.z;
}
int main() {
  int n;
  scanf("%d", &n);
  for (register int i = 1; i <= n; i += 1) scanf("%d", &a[i].x);
  for (register int i = 1; i <= n; i += 1) scanf("%d", &a[i].y);
  for (register int i = 1; i <= n; i += 1) scanf("%d", &a[i].z);
  sort(a + 1, a + n + 1, cmp);
  m[1000000007] = -1000000007;
  m[-1000000007] = 1000000007;
  for (register int i = n; i >= 1; i -= 1) {
    it = m.upper_bound(a[i].y);
    if (it->second > a[i].z)
      ans += 1;
    else if (m[a[i].y] < a[i].z) {
      m[a[i].y] = a[i].z;
      for (it = --m.lower_bound(a[i].y); it->second < a[i].z;) m.erase(it--);
    }
  }
  printf("%d", ans);
  return 0;
}
