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

using ll = long long;

const int maxn = 3e5;
const int inf = 1e9 + 239;
vector<vector<int>> g(maxn, vector<int>(0));
vector<int> d(maxn, 0);

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

void solve() {
  int n, qq;
  cin >> n >> qq;
  vector<int> s(n);
  vector<int> p(n, -1);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    p[i]--;
    g[p[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  dfs(0);
  /*
  vector<int> ord(n);
  priority_queue<pair<int, int>> q;
  q.push({ s[0], 0 });
  int i = 0;
  while (!q.empty()) {
    int u = q.top().second;
    ord[i] = u;
    q.pop();
    for (int w : g[u]) {
      q.push({ s[w], w });
    }
    i++;
  }
  vector<int> pos(n, 0);
  for (int i = 0; i < n; i++) {
    pos[ord[i]] = i;
  }
  vector<vector<int>> after(n, vector<int>(0));
  for (int i = n - 1; i >= 0; i--) {
    int v = ord[i];
    after[v].push_back(i);
    if (p[v] != -1) {
      for (auto u : after[v]) {
        after[p[v]].push_back(u);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    sort(after[i].begin(), after[i].end());
  }
  */
  while (qq--) {
    int v;
    cin >> v;
    v--;
    cout << d[v] << '\n';
    /*
    int def = pos[v];
    int ans = pos[v];
    while (p[v] != -1) {
      for (int u : g[p[v]]) {
        if (u == v) continue;
        int l = -1, r = after[u].size();
        while (r - l > 1) {
          int m = (r + l) / 2;
          if (after[u][m] <= def) {
            l = m;
          }
          else {
            r = m;
          }
        }
        ans = min(ans, def - r);
      }
      v = p[v];
    }
    cout << ans << '\n';
    */
  }
}

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