#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
const int fx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
const int fxx[9][2] = {{0, 0}, {0, 1},  {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
const int N = 500;
const long long mod = 1000000007;
struct FenwickTreeMax {
  vector<long long> bit;
  long long n;
  FenwickTreeMax(long long n) {
    this->n = n;
    bit.assign(n, -1);
  }
  FenwickTreeMax(vector<long long> a) : FenwickTreeMax(a.size()) {
    for (size_t i = 0; i < a.size(); i++) update(i, a[i]);
  }
  long long getmax(long long r) {
    long long ret = -1;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret = (ret < bit[r] ? bit[r] : ret);
    return ret;
  }
  void update(long long idx, long long val) {
    for (; idx < n; idx = idx | (idx + 1))
      bit[idx] = (bit[idx] < val ? val : bit[idx]);
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<pair<long long, long long>> lady;
  set<long long> y;
  vector<long long> a(n), b(n), c(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (long long i = 0; i < n; i++) {
    lady.push_back({a[i], i});
    y.insert(-b[i]);
  }
  sort(lady.begin(), lady.end(), greater<pair<long long, long long>>());
  unordered_map<long long, long long> conv;
  long long cnt = 0;
  for (auto x : y) {
    conv.emplace(-x, cnt++);
  }
  FenwickTreeMax ft(cnt);
  vector<long long> curr;
  long long val = lady[0].first;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long A = lady[i].first;
    long long B = b[lady[i].second];
    long long C = c[lady[i].second];
    if (A != val) {
      for (auto x : curr) {
        ft.update(conv[b[lady[x].second]], c[lady[x].second]);
      }
      curr.clear();
    }
    curr.push_back(i);
    val = A;
    if (C < ft.getmax(conv[B] - 1)) {
      ans++;
    }
  }
  cout << ans << "\n";
}
