#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
struct point {
  int x, y, z, id;
  void read() { scanf("%d%d%d", &x, &y, &z); }
  friend bool operator<(const point &p, const point &q) {
    if (p.x != q.x) return p.x > q.x;
    if (p.y != q.y) return p.y < q.y;
    return p.z < q.z;
  }
} a[N], ta[N];
int c[N];
int lowbit(int x) { return x & (-x); }
void insert(int x, int y) {
  for (int i = x; i < N; i += lowbit(i)) c[i] += y;
}
int query(int x) {
  int ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) ans += c[i];
  return ans;
}
bool ans[N];
bool cmp(const point p, const point q) {
  if (p.y != q.y) return p.y > q.y;
  return p.z > q.z;
}
bool cmpp(const point &p, const point &q) { return p.id < q.id; }
map<int, int> ma;
void solve(int lt, int rt) {
  if (lt == rt) return;
  int mid = (lt + rt) / 2;
  int lc = lt - 1, rc = mid;
  for (int i = lt; i <= rt; i++) ta[a[i].id <= mid ? ++lc : ++rc] = a[i];
  for (int i = lt; i <= rt; i++) a[i] = ta[i];
  int z = -1;
  for (int i = mid + 1, j = lt; i <= rt; i++) {
    while (j <= mid && a[j].y > a[i].y) {
      z = max(z, a[j].z);
      j++;
    }
    if (z > a[i].z) ans[a[i].id] = true;
  }
  solve(mid + 1, rt);
  solve(lt, mid);
}
void read(int &x) {
  x = 0;
  char c;
  while (1) {
    c = getchar();
    if (isdigit(c)) break;
  }
  x = c - '0';
  while (1) {
    c = getchar();
    if (isdigit(c))
      x = 10 * x + (c - '0');
    else
      return;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) read(a[i].x);
  for (int i = 1; i <= n; i++) read(a[i].y);
  for (int i = 1; i <= n; i++) read(a[i].z);
  memset(c, 0, sizeof(c));
  memset(ans, false, sizeof(ans));
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) a[i].id = i;
  sort(a + 1, a + n + 1, cmp);
  solve(1, n);
  int sum = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) sum++;
  cout << sum << endl;
  return 0;
}
