#include <bits/stdc++.h>
using namespace std;
struct Node {
  int l, r;
  int sum;
  bool operator<(Node t) const { return l < t.l; }
};
const int N = 2010, M = 2 * N;
int m;
int n;
int h[N], e[M], ne[M], idx;
int lef[N];
int ans;
vector<Node> a;
void add(int a, int b) {
  e[idx] = b, ne[idx] = h[a], h[a] = idx++;
  e[idx] = a, ne[idx] = h[b], h[b] = idx++;
}
Node dfs(int u, int pa) {
  Node t;
  if (lef[u]) {
    t.l = t.r = lef[u];
    t.sum = 1;
    if (u == 1) t.sum--;
    a.push_back(t);
    return t;
  }
  t.l = 0x3f3f3f3f, t.r = -t.l, t.sum = 0;
  for (int i = h[u]; i != -1; i = ne[i]) {
    int j = e[i];
    if (j == pa) continue;
    Node temp = dfs(j, u);
    t.l = min(t.l, temp.l), t.r = max(t.r, temp.r);
    t.sum += temp.sum;
  }
  t.sum++;
  if (u == 1) t.sum--;
  a.push_back(t);
  return t;
}
void init() {
  memset(h, -1, sizeof h);
  idx = 0;
  memset(lef, 0, sizeof lef);
  scanf("%d", &n);
  ans += n - 1;
  for (int i = 2; i <= n; i++) {
    int pa;
    scanf("%d", &pa);
    add(pa, i);
  }
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    lef[x] = i;
  }
  dfs(1, 0);
}
int f[N];
int main() {
  scanf("%d", &m);
  init();
  init();
  sort(a.begin(), a.end());
  memset(f, 0, sizeof f);
  int p = 0;
  for (int i = 1; i <= m; i++) {
    while (p < a.size() && a[p].l == i) {
      f[a[p].r + 1] = max(f[a[p].r + 1], f[i] + a[p].sum);
      p++;
    }
  }
  cout << f[m + 1] << endl;
  return 0;
}
