#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, z;
  int cnt, amount;
} a[500000 + 5];
bool cmpxyz(node a, node b) {
  if (a.x != b.x) return a.x < b.x;
  if (a.y != b.y) return a.y > b.y;
  return a.z > b.z;
}
bool cmpyz(node a, node b) {
  if (a.y != b.y) return a.y < b.y;
  return a.z < b.z;
}
int t[500000 + 5];
void add(int x, int v) {
  for (; x <= 500000; x += x & -x) t[x] += v;
}
int ask(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += t[x];
  return res;
}
void solve(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  solve(l, mid);
  solve(mid + 1, r);
  sort(a + l, a + mid + 1, cmpyz);
  sort(a + mid + 1, a + r + 1, cmpyz);
  int i1 = mid, i2 = r;
  while (i1 >= l || i2 >= mid + 1) {
    if (i1 >= l && i2 >= mid + 1) {
      if (a[i1].y < a[i2].y)
        add(a[i2].z, a[i2].amount), i2--;
      else
        a[i1].cnt += r - i2 - ask(a[i1].z), i1--;
    } else if (i2 >= mid + 1)
      add(a[i2].z, a[i2].amount), i2--;
    else
      a[i1].cnt += r - i2 - ask(a[i1].z), i1--;
  }
  for (int i = mid + 1; i <= r; i++) add(a[i].z, -a[i].amount);
}
void fuck(int l, int r) {
  for (int i = r; i >= l; i--) {
    a[i].cnt -= r - i - ask(a[i].z);
    add(a[i].z, a[i].amount);
  }
  for (int i = l; i <= r; i++) add(a[i].z, -a[i].amount);
  ;
}
vector<int> vec;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &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);
  for (int i = 1; i <= n; i++) vec.push_back(a[i].z);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 1; i <= n; i++)
    a[i].z = lower_bound(vec.begin(), vec.end(), a[i].z) - vec.begin() + 1;
  sort(a + 1, a + n + 1, cmpxyz);
  int m = 0;
  for (int i = 1; i <= n; i++) a[++m] = a[i], a[m].amount++;
  solve(1, m);
  int ans = 0;
  for (int i = 1; i <= m; i++)
    if (a[i].cnt) ans += a[i].amount;
  printf("%d\n", ans);
  return 0;
}
