#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 3e5 + 1;

int n, Q;
vector<int> g[maxn];

int tin[maxn], tout[maxn], timer = 0;
int sz[maxn], depth[maxn], p[maxn];
int vals[maxn];
map<int, int> pos_vertex[maxn];
vector<pair<int, int>> trees[maxn];
set<int> was_del;


void build(int vertex, int v, int tl, int tr) {
   if (tl == tr) {
      trees[vertex][v] = make_pair(sz[g[vertex][tl]], sz[g[vertex][tl]]);
      return;
   }
   int tm = (tl + tr) >> 1;
   build(vertex, v << 1, tl, tm);
   build(vertex, v << 1 | 1, tm + 1, tr);
   trees[vertex][v].first = max(trees[vertex][v << 1].first, trees[vertex][v << 1 | 1].first);
   trees[vertex][v].second = trees[vertex][v << 1].second + trees[vertex][v << 1 | 1].second;
}

int dfs(int v) {
   //cout << "DFS: " << v << endl;
   tin[v] = timer++;
   sz[v] = 1;

   for (int u : g[v]) {
      depth[u] = depth[v] + 1;
      sz[v] += dfs(u);
   }

   for (int i = 0; i < g[v].size(); i++) {
      pos_vertex[v][g[v][i]] = i;
   }

   if (g[v].size()) {

      trees[v].resize((g[v].size() + 1) * 4);
      build(v, 1, 0, g[v].size() - 1);

   }
   tout[v] = timer--;
   return sz[v];
}

void update(int vertex, int pos, int val, int v, int tl, int tr) {
   if (tl == tr && tl == pos) {
      trees[vertex][v] = make_pair(val, val);
      return;
   }

   if (tr < pos || pos < tl) {
      return;
   }
   int tm = (tl + tr) >> 1;
   update(vertex, pos, val, v << 1, tl, tm);
   update(vertex, pos, val, v << 1 | 1, tm + 1, tr);
   trees[vertex][v].first = max(trees[vertex][v << 1].first, trees[vertex][v << 1 | 1].first);
   trees[vertex][v].second = trees[vertex][v << 1].second + trees[vertex][v << 1 | 1].second; 
}


void update_tree(int val) {
   int vertex = vals[val], vertex_sz = sz[vertex];
   was_del.insert(vertex);
   //cout << "UPD: " << vertex + 1 << ' ' << vertex_sz << '\n';
   sz[vertex] -= vertex_sz;
   while (vertex != 0) {
      int cur_v = p[vertex];

      update(cur_v, pos_vertex[cur_v][vertex], sz[vertex], 1, 0, g[cur_v].size() - 1);

      vertex = cur_v;
      sz[vertex] -= vertex_sz;
      if (was_del.count(vertex)) {
         break;
      }
   }
}

pair<int, int> get(int vertex, int l, int r, int v, int tl, int tr) {
   if (l <= tl && tr <= r) {
      return trees[vertex][v];
   }
   if (tr < l || r < tl) {
      return make_pair(0, 0);
   }
   int tm = (tl + tr) >> 1;
   auto lhs = get(vertex, l, r, v << 1, tl, tm);
   auto rhs = get(vertex, l, r, v << 1 | 1, tm + 1, tr);
   return make_pair(max(lhs.first, rhs.first), lhs.second + rhs.second);
}

int ask(int v) {
   int mx = 0, sum = 0;
   //cout << "ASKING: " << v + 1 << endl;
   while (v != 0) {
      int cur_v = p[v];
      //cout << "CUR_V: " << cur_v + 1 << " pos " << pos_vertex[cur_v][v] << endl;

      sum++;
      auto [cur_mx_l, cur_sum_l] = get(cur_v, 0, pos_vertex[cur_v][v] - 1, 1, 0, g[cur_v].size() - 1);
      sum += cur_sum_l;
      mx = max(cur_mx_l, mx);
      auto [cur_mx_r, cur_sum_r] = get(cur_v, pos_vertex[cur_v][v] + 1, g[cur_v].size() - 1, 1, 0, g[cur_v].size() - 1);
      sum += cur_sum_r;
      mx = max(cur_mx_r, mx);
      //cout << "STATE: " << sum << ' ' << mx << " lol: " << cur_sum_l << ' ' << cur_sum_r << endl;
      v = cur_v;
   }
   return sum - mx;
}

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

   cin >> n >> Q;

   p[0] = -1;
   for (int i = 1; i < n; i++) {
      cin >> p[i];
      --p[i];
      g[p[i]].push_back(i);
   }
   dfs(0);


   vector<int> his_val(n);
   for (int i = 0, s; i < n; i++) {
      cin >> s;
      vals[s] = i;
      his_val[i] = s;
   }


   vector<int> queries(Q);

   for (int &i : queries) {
      cin >> i;
      --i;
   }

   vector<int> p(Q);
   iota(p.begin(), p.end(), 0);
   sort(p.begin(), p.end(), [&](int x, int y) {
         return his_val[queries[x]] < his_val[queries[y]];
   });


   vector<int> ans(Q);
   int cur_val = 1;
   for (int i = 0; i < Q; i++) {
      //cout << "UPD" << endl;
      while (cur_val < his_val[queries[p[i]]]) {
         update_tree(cur_val);
         cur_val += 1;
      }
      //cout << "ASK ON: " << p[i] << ": " << queries[p[i]] + 1 << endl;
      ans[p[i]] = ask(queries[p[i]]);
   }

   for (int i : ans) {
      cout << i << ' ';
   }

   return 0;
}
