#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <fstream>
#include <unordered_map>
#include <algorithm>
using namespace std;

using ll = long long;

const int maxn = 3e5;
const int inf = 1e9 + 239;

void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> s(n);
  vector<int> p(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    a[i] = { s[i], i };
  }
  a[0].first = inf;
  sort(a.begin(), a.end());
  vector<int> ind(n, 0);
  for (int i = 0; i < n; i++) {
    ind[a[i].second] = i;
  }
  while (q--) {
    int v;
    cin >> v;
    v--;
    if (v == 0) {
      cout << 0 << '\n';
      continue;
    }
    int ans = n - 1 - ind[v];
    if (ind[v] != n - 2) {
      ans--;
    }
    cout << ans << '\n';
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
