#include <bits/stdc++.h>
using namespace std;
class suicide {
 public:
  int x, y, z;
  bool operator<(const suicide& b) const {
    if (z == b.z)
      if (x == b.x)
        return y < b.y;
      else
        return x < b.x;
    else
      return z > b.z;
  }
  void p() { printf("%d %d %d\n", x, y, z); }
};
const int MAX = 500009;
suicide vc[MAX];
int n;
int brutus() {
  int res = 0;
  for (int i = 0; i < n; i++) {
    bool sw = false;
    for (int j = 0; !sw and j < n; j++)
      sw = (vc[i].x < vc[j].x and vc[i].y < vc[j].y and vc[i].z < vc[j].z);
    res += sw;
  }
  return res;
}
void leer() {
  for (int i = 0; i < n; i++) scanf("%d", &vc[i].x);
  for (int i = 0; i < n; i++) scanf("%d", &vc[i].y);
  for (int i = 0; i < n; i++) scanf("%d", &vc[i].z);
}
void imprime() {
  printf("%d\n", n);
  for (int i = 0; i < n; i++) vc[i].p();
}
int resuelva() {
  map<int, suicide> mp;
  int res = 0;
  int x, y, z;
  suicide s;
  sort(vc, vc + n);
  mp.insert(pair<int, suicide>(vc[0].x, vc[0]));
  for (int i = 1; i < n; i++) {
    s = vc[i];
    x = s.x;
    y = s.y;
    z = s.z;
    map<int, suicide>::iterator it, end = mp.end(), start;
    it = mp.lower_bound(x);
    if (it != mp.end()) {
      if (s.x < it->second.x and s.y < it->second.y and z < it->second.z)
        res++;
      else {
        if (it->second.x == x) {
          it++;
          if (it != mp.end() and s.x < it->second.x and s.y < it->second.y and
              z < it->second.z)
            res++;
          it--;
          if (y > it->second.y) {
            end = it;
            end->second.y = y;
            end->second.z = z;
          } else {
            res++;
            res--;
          }
        } else if (y > it->second.y)
          end = mp.insert(pair<int, suicide>(x, s)).first;
      }
    } else {
      end = mp.insert(pair<int, suicide>(x, s)).first;
    }
    if (end != mp.end()) {
      start = end;
      while (start != mp.begin() and start->second.y <= y) start--;
      if (start->second.y > y) start++;
      mp.erase(start, end);
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  leer();
  printf("%d\n", resuelva());
  return 0;
  int c = 1;
  while (scanf("%d", &n) != EOF) {
    leer();
    int a = resuelva();
    int b = brutus();
    if (a != b) {
      imprime();
      printf("logN %d %d brutus\n", a, b);
    }
  }
}
