#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y, z;
};
const long long sz = 500000;
point v[sz];
long long t[4 * sz];
long long pv[4 * sz];
long long n;
long long ZIP() {
  long long ret = -1;
  map<long long, long long> eq;
  long long c = 0;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    a.push_back(v[i].x);
  }
  sort(a.begin(), a.end());
  eq[a[0]] = c;
  for (long long i = 1; i < a.size(); i++) {
    if (a[i] != a[i - 1]) c++;
    eq[a[i]] = c;
  }
  for (long long i = 0; i < a.size(); i++) {
    v[i].x = eq[v[i].x];
  }
  ret = max(ret, c);
  c = 0;
  a.clear();
  eq.clear();
  for (long long i = 0; i < n; i++) {
    a.push_back(v[i].y);
  }
  sort(a.begin(), a.end());
  eq[a[0]] = c;
  for (long long i = 1; i < a.size(); i++) {
    if (a[i] != a[i - 1]) c++;
    eq[a[i]] = c;
  }
  for (long long i = 0; i < a.size(); i++) {
    v[i].y = eq[v[i].y];
  }
  ret = max(ret, c);
  c = 0;
  a.clear();
  eq.clear();
  for (long long i = 0; i < n; i++) {
    a.push_back(v[i].z);
  }
  sort(a.begin(), a.end());
  eq[a[0]] = c;
  for (long long i = 1; i < a.size(); i++) {
    if (a[i] != a[i - 1]) c++;
    eq[a[i]] = c;
  }
  for (long long i = 0; i < a.size(); i++) {
    v[i].z = eq[v[i].z];
  }
  ret = max(ret, c);
  return ret;
}
void push(long long _v) {
  if (pv[_v] != -1) {
    if (t[_v] < pv[_v]) t[_v] = pv[_v];
    if (_v * 2 + 1 < 4 * sz) {
      pv[_v * 2] = max(pv[_v], pv[_v * 2]);
      pv[_v * 2 + 1] = max(pv[_v], pv[_v * 2 + 1]);
    }
    pv[_v] = -1;
  }
}
void query(long long _v, long long tl, long long tr, long long l, long long r,
           long long val) {
  push(_v);
  if (l > r) return;
  if (l == tl && r == tr) {
    pv[_v] = max(pv[_v], val);
    push(_v);
    return;
  }
  long long m = (tl + tr) / 2;
  query(_v * 2, tl, m, l, min(r, m), val);
  query(_v * 2 + 1, m + 1, tr, max(m + 1, l), r, val);
  t[_v] = max(t[_v * 2], t[_v * 2 + 1]);
}
long long get(long long _v, long long tl, long long tr, long long l,
              long long r) {
  push(_v);
  if (l > r) return -1;
  if (l == tl && r == tr) {
    return t[_v];
  }
  long long m = (tl + tr) / 2;
  return max(get(_v * 2, tl, m, l, min(r, m)),
             get(_v * 2 + 1, m + 1, tr, max(l, m + 1), r));
  t[_v] = max(t[_v * 2], t[_v * 2 + 1]);
}
int32_t main() {
  memset(t, -1, sizeof(t));
  memset(pv, -1, sizeof(pv));
  scanf("%d", &n);
  for (long long i = 0; i < n; i++) scanf("%d", &v[i].x);
  for (long long i = 0; i < n; i++) scanf("%d", &v[i].y);
  for (long long i = 0; i < n; i++) scanf("%d", &v[i].z);
  long long MAX = ZIP();
  sort(v, v + n, [](const point& p1, const point& p2) {
    if (p1.x != p2.x) return p1.x < p2.x;
    if (p1.y != p2.y) return p1.y > p2.y;
    return p1.z < p2.z;
  });
  for (long long i = 0; i < n; i++) {
  }
  long long ans = 0;
  for (long long i = n - 1; i >= 0; i--) {
    long long MX = get(1, 0, MAX, v[i].y + 1, MAX);
    if (MX > v[i].z) {
      ans++;
    } else {
      query(1, 0, MAX, 0, v[i].y, v[i].z);
    }
  }
  cout << ans;
}
