#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int maxE;
bool cmp(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  return a.first > b.first;
}
struct node {
  int val;
  node *left, *right;
  node() { val = 0, left = NULL, right = NULL; }
};
void update(int start, int end, node*& r, int x, int v) {
  if (r == NULL) {
    r = new node;
  }
  r->val = max(v, r->val);
  int mid = (start + end) / 2;
  if (start == end) {
  } else if (x <= mid)
    update(start, mid, r->left, x, v);
  else
    update(mid + 1, end, r->right, x, v);
}
int query(int start, int end, node*& r, int a, int b) {
  if (r == NULL) {
    return 0;
  }
  if (start >= a && end <= b)
    return r->val;
  else if (start > b || end < a)
    return 0;
  else {
    int mid = (start + end) / 2;
    return max(query(start, mid, r->left, a, b),
               query(mid + 1, end, r->right, a, b));
  }
}
pair<int, pair<int, int>> arr_input[3 * N];
pair<int, pair<int, int>> arr[N];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr_input[i].first);
    arr_input[i].second.first = i, arr_input[i].second.second = 1;
  }
  for (int i = n + 1; i <= 2 * n; i++) {
    scanf("%d", &arr_input[i].first);
    arr_input[i].second.first = i - n, arr_input[i].second.second = 2;
  }
  for (int i = 2 * n + 1; i <= 3 * n; i++) {
    scanf("%d", &arr_input[i].first);
    arr_input[i].second.first = i - 2 * n, arr_input[i].second.second = 3;
  }
  sort(arr_input + 1, arr_input + 1 + 3 * n);
  int i = 1, h;
  int count = 0, ans = 0;
  maxE = 0;
  while (i <= 3 * n) {
    h = i;
    maxE++;
    while (i <= 3 * n && arr_input[h].first == arr_input[i].first) {
      if (arr_input[i].second.second == 1) {
        arr[arr_input[i].second.first].first = maxE;
      } else if (arr_input[i].second.second == 2) {
        arr[arr_input[i].second.first].second.first = maxE;
      } else if (arr_input[i].second.second == 3) {
        arr[arr_input[i].second.first].second.second = maxE;
      }
      i++;
    }
  }
  sort(arr + 1, arr + 1 + n, cmp);
  i = 1;
  node* root = NULL;
  while (i <= n) {
    h = i;
    while (i <= n && arr[h].first == arr[i].first) {
      if (query(1, maxE, root, arr[i].second.first + 1, maxE) >
          arr[i].second.second) {
        ans++;
      }
      i++;
    }
    for (int j = h; j < i; j++) {
      update(1, maxE, root, arr[j].second.first, arr[j].second.second);
    }
  }
  cout << ans << endl;
  return 0;
}
