#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;

constexpr int buffer_size = 1 << 20;
constexpr char my_flush = '@';

char read_char() {
  static char cache[buffer_size];
  static int pos = 0;
  static int sz = 0;
  if (pos == sz) {
    sz = fread(cache, 1, buffer_size, stdin);
    pos = 0;
  }
  if (pos == sz) {
    return EOF;
  }
  return cache[pos++];
}

void write_char(char c) {
  static char cache[buffer_size];
  static int pos = 0;
  if (pos == buffer_size || c == my_flush) {
    fwrite(cache, 1, pos, stdout);
    pos = 0;
  }
  if (c != my_flush) {
    cache[pos++] = c;
  }
}

template<typename T>
void write_num(T x) {
  char st[64];
  int pos = 0;
  if (x < 0) {
    write_char('-');
    x = -x;
  }
  do {
    st[pos++] = char('0' + x % 10);
    x /= 10;
  } while (x > 0);
  while (pos > 0) {
    write_char(st[--pos]);
  }
}

template<typename T = int>
T read_num() {
  bool sign = false;
  char c;
  T res = 0;
  for (;;) {
    c = read_char();
    if (c == '-') {
      sign = true;
    }
    if (!isdigit(c)) {
      break;
    }
    res = res * 10 + (c - '0');
  }
  return res;
}

string read_str() {
  string ans;
  char c;
  for (;;) {
    c = read_char();
    if (isalnum(c) || isgraph(c)) {
      ans.push_back(c);
    } else {
      break;
    }
  }
  return move(ans);
}

void print_str(const string& s) {
  for (auto c : s) {
    write_char(c);
  }
}

struct segtree {
  struct node {
    int mx, add, av;

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

  vector<node> t;
  vector<pair<int*, int>> cache;
  vector<int> changes_cnt;
  int N;

  segtree(int n = 0) : N(n), t(__bit_ceil(n) * 2) {}

  void apply_av(int x, bool need_cache = true) {
    if (need_cache) {
      cache.emplace_back(&t[x].mx, t[x].mx);
      cache.emplace_back(&t[x].av, t[x].av);
      cache.emplace_back(&t[x].add, t[x].add);
      changes_cnt.back() += 3;
    }
    t[x].mx = t[x].av = t[x].add = 0;
  }

  void apply_add(int x, bool need_cache = true) {
    if (need_cache) {
      cache.emplace_back(&t[x].mx, t[x].mx);
      cache.emplace_back(&t[x].add, t[x].add);
      changes_cnt.back() += 2;
    }
    t[x].mx += 1;
    t[x].add += 1;
  }

  void push(int x, bool need_cache = true) {
    if (t[x].av == -1) return;
    apply_av(x * 2 + 1);
    apply_av(x * 2 + 2);
    if (need_cache) {
      cache.emplace_back(&t[x].av, t[x].av);
      changes_cnt.back() += 1;
    }
    t[x].av = -1;
  }

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

  void set(int lq, int rq, int x, int lx, int rx) {
    if (rx <= lq || lx >= rq) return;
    if (lq <= lx && rx <= rq) {
      apply_av(x);
      return;
    }
    int m = (lx + rx) / 2;
    push(x);
    set(lq, rq, x * 2 + 1, lx, m);
    set(lq, rq, x * 2 + 2, m, rx);
    t[x].mx = max(t[x * 2 + 1].mx, t[x * 2 + 2].mx) + t[x].add;
  }

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

  void add(int lq, int rq, int x, int lx, int rx) {
    if (rx <= lq || lx >= rq) return;
    if (lq <= lx && rx <= rq) {
      apply_add(x,0);
      return;
    }
    int m = (lx + rx) / 2;
    push(x,0);
    add(lq, rq, x * 2 + 1, lx, m);
    add(lq, rq, x * 2 + 2, m, rx);
    t[x].mx = max(t[x * 2 + 1].mx, t[x * 2 + 2].mx) + t[x].add;
  }

  int get() {
    return t[0].mx;
  }

  void rollback() {
    while (changes_cnt.back() --> 0) {
      auto [ptr, val] = cache.back();
      cache.pop_back();
      *ptr = val;
    }
    changes_cnt.pop_back();
  }
};

vector<vector<int>> g;
vector<int> p, tin, s, ans, sz, head;
segtree st;
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;
  n = read_num();
  q = read_num();
  st = move(segtree(n));
  g.assign(n + 1, {});
  p.resize(n + 1);
  sz.resize(n + 1);
  tin.resize(n + 1);
  ans.resize(n + 1);
  head.resize(n + 1);
  s.resize(n + 1);
  for (int i = 2; i <= n; ++i) {
    // cin >> p[i];
    p[i] = read_num();
    g[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    // cin >> s[i];
    s[i] = read_num();
  }
  dfs();
  decomp();
  sz.clear();
  sz.shrink_to_fit();
  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);
      }
    }
  }
  g.clear();
  g.shrink_to_fit();
  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;
    u = read_num();
    // cout << ans[u] << ' ';
    write_num(ans[u]);
    write_char(' ');
  }
  // cout << '\n';
  write_char('\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();
  }
}