#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
struct Max {
  vector<int> d;
  int n;
  void Init(int n) {
    this->n = n;
    d.resize(n * 2, 0);
  }
  void Set(int p, int v) {
    p += n;
    d[p] = max(d[p], v);
    for (p >>= 1; p > 0; p >>= 1) {
      d[p] = max(d[p * 2], d[p * 2 + 1]);
    }
  }
  int Get(int a, int b) {
    int res = 0;
    for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if (a & 1) res = max(res, d[a++]);
      if (b & 1) res = max(res, d[--b]);
    }
    return res;
  }
};
struct P {
  typedef const P& CP;
  int x, y, z;
  P() {}
  friend bool operator<(CP a, CP 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;
  }
};
int n;
vector<P> pp;
vector<int> dify;
map<int, int> my;
Max mm;
int main() {
  scanf("%d", &n);
  pp.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &pp[i].x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &pp[i].y);
    dify.push_back(pp[i].y);
  }
  for (int i = 0; i < n; i++) scanf("%d", &pp[i].z);
  sort(dify.begin(), dify.end());
  dify.erase(unique(dify.begin(), dify.end()), dify.end());
  for (int i = 0; i < dify.size(); i++) {
    my[dify[i]] = i;
  }
  int maxy = dify.size();
  mm.Init(maxy);
  sort(pp.begin(), pp.end());
  int res = 0;
  for (int i = n - 1; i >= 0;) {
    int k = i;
    while (k > 0 && pp[k - 1].x == pp[i].x) {
      k--;
    }
    for (int j = k; j <= i; j++) {
      int m = mm.Get(my[pp[j].y] + 1, maxy);
      if (m > pp[j].z) {
        res++;
      }
    }
    for (int j = k; j <= i; j++) {
      mm.Set(my[pp[j].y], pp[j].z);
    }
    i = k - 1;
  }
  printf("%d\n", res);
  return 0;
}
