#ifndef LOCAL
  #pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
  #pragma GCC target("avx,avx2,fma")
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

const int maxn = 3e5 + 1;

struct segtree {
  struct node {
    int mx, av, add;
    shared_ptr<node> l;
    shared_ptr<node> r;

    node(int v = 0) : mx(v), add(0), av(-1), l(0), r(0) {}

    node(shared_ptr<node> n) : mx(n->mx), add(n->add), av(n->av), l(n->l), r(n->r) {}
  };

  int get_max(shared_ptr<node> n) {
    return n ? n->mx : 0;
  }

  vector<shared_ptr<node>> cache;
  int N;

  segtree(int n = 0) : N(n), cache{0} {}

  void apply_av(shared_ptr<node> n, int av) {
    n->mx = n->av = av;
    n->add = 0;
  }

  void apply_add(shared_ptr<node> n, int add) {
    n->mx += add;
    n->add += add;
  }

  shared_ptr<node> push(shared_ptr<node> n) {
    if (!n->l) n->l = make_shared<node>();
    n->l = make_shared<node>(n->l);
    if (!n->r) n->r = make_shared<node>();
    n->r = make_shared<node>(n->r);
    if (n->av != -1) {
      apply_av(n->l, n->av);
      apply_av(n->r, n->av);
      n->av = -1;
      n->add = 0;
    }
    return n;
  }

  void set(int lq, int rq) {
    cache.push_back(set(lq, rq, 0, N, cache.back()));
  }

  shared_ptr<node> set(int lq, int rq, int lx, int rx, shared_ptr<node> n) {
    if (rx <= lq || lx >= rq) return n;
    if (!n) n = make_shared<node>();
    n = make_shared<node>(n);
    if (lq <= lx && rx <= rq) {
      apply_av(n, 0);
      return n;
    }
    n = push(n);
    int m = (lx + rx) / 2;
    n->l = set(lq, rq, lx, m, n->l);
    n->r = set(lq, rq, m, rx, n->r);
    n->mx = max(n->l->mx, n->r->mx) + n->add;
    return n;
  }

  void add(int lq, int rq) {
    cache.push_back(add(lq, rq, 0, N, cache.back()));
  }

  shared_ptr<node> add(int lq, int rq, int lx, int rx, shared_ptr<node> n) {
    if (rx <= lq || lx >= rq) return n;
    if (!n) n = make_shared<node>();
    n = make_shared<node>(n);
    if (lq <= lx && rx <= rq) {
      apply_add(n, 1);
      return n;
    }
    n = push(n);
    int m = (lx + rx) / 2;
    n->l = add(lq, rq, lx, m, n->l);
    n->r = add(lq, rq, m, rx, n->r);
    n->mx = max(n->l->mx, n->r->mx) + n->add;
    return n;
  }

  int get() {
    return get_max(cache.back());
  }

  void rollback() {
    cache.pop_back();
  }
} st(maxn);

vector<int> g[maxn];
int p[maxn], tin[maxn], s[maxn], ans[maxn], sz[maxn], head[maxn];
int n, q;
int tt = 0;

void dfs(int u = 1) {
  sz[u] = 1;
  for (int& v : g[u]) {
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > sz[g[u][0]]) {
      swap(v, g[u][0]);
    }
  }
}

void decomp(int u = 1, int h = 1) {
  tin[u] = tt++;
  head[u] = h;
  if (!g[u].empty()) {
    decomp(g[u][0], h);
  }
  for (int v : g[u]) {
    if (v == g[u][0]) {
      continue;
    }
    decomp(v, v);
  }
}

int par_set(int u) {
  int cnt = 0;
  while (head[u] != 1) {
    st.set(tin[head[u]], tin[u] + 1);
    u = p[head[u]];
    ++cnt;
  }
  st.set(tin[1], tin[u] + 1);
  ++cnt;
  return cnt;
}

void par_add(int u) {
  while (head[u] != 1) {
    st.add(tin[head[u]], tin[u] + 1);
    u = p[head[u]];
  }
  st.add(tin[1], tin[u] + 1);
}

void solve() {
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  dfs();
  decomp();
  vector<int> h;
  set<pair<int, int>, greater<>> val;
  val.emplace(s[1], 1);
  while (!val.empty()) {
    int u = val.begin()->second;
    h.push_back(u);
    val.erase(val.begin());
    for (int v : g[u]) {
      val.emplace(s[v], v);
    }
  }
  for (int i = 0; i < n; ++i) {
    int c = par_set(h[i]);
    ans[h[i]] = i - st.get();
    while (c --> 0) {
      st.rollback();
    }
    par_add(h[i]);
  }
  for (int i = 0; i < q; ++i) {
    int u;
    cin >> u;
    cout << ans[u] << ' ';
  }
  cout << '\n';
}

signed main() {
  // freopen("in", "r", stdin);
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}