#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int INF = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const int MOD = 1000000007;
const double eps = 1e-7;
void print(int x) {
  cout << x << endl;
  exit(0);
}
void PRINT(string x) {
  cout << x << endl;
  exit(0);
}
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
int num[N], bit[N];
int n;
struct node {
  int x, y, z;
} a[N];
bool cmp(node a, node b) { return a.y > b.y; }
void lsh() {
  sort(num + 1, num + n + 1);
  int t = unique(num + 1, num + n + 1) - (num + 1);
  for (int i = (1); i <= (n); i++)
    a[i].x = t - (lower_bound(num + 1, num + 1 + t, a[i].x) - (num + 1));
}
void add(int x, int y) {
  for (; x < N; x += (x & -x)) bit[x] = max(bit[x], y);
}
int ask(int x) {
  int ans = 0;
  for (; x; x -= (x & -x)) ans = max(ans, bit[x]);
  return ans;
}
signed main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i].x), num[i] = a[i].x;
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i].y);
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i].z);
  lsh();
  sort(a + 1, a + n + 1, cmp);
  int ans = 0;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && a[j].y == a[i].y; j++) {
      int z = ask(a[j].x - 1);
      if (z > a[j].z) ans++;
    }
    for (; i < j; i++) add(a[i].x, a[i].z);
  }
  printf("%d\n", ans);
  return 0;
}
