#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
inline long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long power(long long a, long long n, long long m) {
  if (n == 0) return 1;
  long long p = power(a, n / 2, m);
  p = (p * p) % m;
  if (n % 2)
    return (p * a) % m;
  else
    return p;
}
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
int bit[2000001];
int getparent(int i) { return i - (i & (-i)); }
int getnext(int i) { return i + (i & (-i)); }
int getmaximum(int r) {
  int mx = 0;
  while (r > 0) {
    mx = max(mx, bit[r]);
    r = getparent(r);
  }
  return mx;
}
void update(int i, int value) {
  while (i <= 2000000) {
    bit[i] = max(bit[i], value);
    i = getnext(i);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  map<long long, int> mp;
  map<long long, int>::iterator it;
  pair<int, pair<int, int> > p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    mp.insert(make_pair(p[i].first, 0));
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i].second.first;
    mp.insert(make_pair(p[i].second.first, 0));
  }
  for (int i = 0; i < n; i++) {
    cin >> p[i].second.second;
    mp.insert(make_pair(p[i].second.second, 0));
  }
  it = mp.begin();
  int k = 1;
  while (it != mp.end()) {
    mp[it->first] = k;
    k++;
    it++;
  }
  sort(p, p + n);
  int j;
  int mx, in;
  int ans = 0;
  for (int i = n - 1; i >= 0;) {
    j = i;
    while (j >= 0 && (p[j].first == p[i].first)) j--;
    for (int m = i; m > j; m--) {
      in = mp[p[m].second.first];
      mx = getmaximum(2000000 - in);
      if (mx > mp[p[m].second.second]) ans++;
    }
    for (int m = i; m > j; m--) {
      in = mp[p[m].second.first];
      if (bit[2000000 - in + 1] < mp[p[m].second.second])
        update(2000000 - in + 1, mp[p[m].second.second]);
    }
    i = j;
  }
  cout << ans << endl;
  return 0;
}
