#include "bits/extc++.h"

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less < T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
istream &operator>>(istream &is, vector <T> &vec) {
      for (auto &elem: vec) is >> elem;
      return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector <T> &vec) {
      for (auto &elem: vec) os << elem << ' ';
      os << '\n';
      return os;
}

//#pragma optimize("Ofast")
//#pragma optimize("unroll-loops")
//#pragma optimize("avx, avx2")

const int NOTH = 0;

struct Push_Node {
      int val, tag;

      Push_Node(int val = 0, int tag = NOTH) : val(val), tag(tag) {}

      void apply(int v, int l, int r) {
            val += (r - l) * v;
            tag += v;
      }

      friend Push_Node operator+(const Push_Node &x, const Push_Node &y) {
            return {x.val + y.val, NOTH};
      }
};

struct Lazy_Segtree {
      int size;
      vector <Push_Node> tree;

      Lazy_Segtree(int n) {
            size = 1;
            while (size < n) size <<= 1;
            tree.resize(size << 1, Push_Node());
      }

      Lazy_Segtree(const vector<int> &a) : Lazy_Segtree(a.size()) {
            for (int i = 0; i < a.size(); ++i) tree[i + size] = a[i];
            for (int i = size - 1; i > 0; --i) tree[i] = tree[i << 1] + tree[i << 1 | 1];
      }

      void push(int x, int lx, int rx) {
            if (rx - lx == 1 or tree[x].tag == NOTH) return;

            int mid = (lx + rx) >> 1;
            tree[x << 1].apply(tree[x].tag, lx, mid);
            tree[x << 1 | 1].apply(tree[x].tag, mid, rx);

            tree[x].tag = NOTH;
      }

      void set(int l, int r, int v, int x, int lx, int rx) {
            push(x, lx, rx);
            if (rx <= l or r <= lx) return;
            if (l <= lx and rx <= r) tree[x].apply(v, lx, rx);
            else {
                  int mid = (lx + rx) >> 1;

                  set(l, r, v, x << 1, lx, mid);
                  set(l, r, v, x << 1 | 1, mid, rx);

                  tree[x] = tree[x << 1] + tree[x << 1 | 1];
            }
      }

      Push_Node get(int l, int r, int x, int lx, int rx) {
            push(x, lx, rx);
            if (rx <= l or r <= lx) return Push_Node();
            if (l <= lx and rx <= r) return tree[x];
            else {
                  int mid = (lx + rx) >> 1;

                  Push_Node s1 = get(l, r, x << 1, lx, mid);
                  Push_Node s2 = get(l, r, x << 1 | 1, mid, rx);

                  return s1 + s2;
            }
      }

      void set(int l, int r, int v) {
            set(l, r, v, 1, 0, size);
      }

      Push_Node get(int l, int r) {
            return get(l, r, 1, 0, size);
      }
};

int dgcd(int a, int b, int &x, int &y) {
      if (a == 0) {
            x = 0, y = 1;
            return b;
      }

      int x1, y1;
      int d = dgcd(b % a, a, x1, y1);
      x = y1 - (b / a) * x1;
      y = x1;

      return d;
}

#define int long long

void solve() {
      int n, q;
      cin >> n >> q;
      vector<int> x(q);
      cin >> x;
      reverse(x.begin(), x.end());

      if (q <= n) {
            cout << accumulate(x.begin(), x.end(), 0ll) << endl;
            return;
      }

      int res = 0;
      vector<int> used(q);
      {
            vector <pair<int, int>> t;
            for (int i = 0; i < q; ++i) t.push_back({x[i], i});
            std::sort(t.rbegin(), t.rend());
            for (int i = 0; i < n; ++i) res += t[i].first, used[t[i].second] = true;

            if (!used[0]) {
                  used[t[n - 1].second] = false;
                  used[0] = true;
                  res -= t[n - 1].first, res += x[0];
            }
      }

      ordered_set<pair < int, int>>
      s;
      for (int i = 0; i < q; ++i) {
            if (used[i]) continue;
            if (s.empty()) {
                  s.insert({x[i], i});
                  continue;
            }
            auto mn = *s.begin();
            if (mn.first < x[i]) {
                  res += x[i] - mn.first;
                  s.erase(mn);
            } else {
                  s.insert({x[i], i});
            }
      }

      vector <pair<int, int>> a = {s.begin(), s.end()};
      std::sort(a.begin(), a.end(), [&](auto b, auto c) {
            return b.second < c.second;
      });

      for (int i = 0; i < a.size(); ++i) {
            if (i & 1) res += a[i].first;
            else res -= a[i].first;
      }

      cout << res << endl;
}

struct Node {
      int s;

      Node(int s = 0) : s(s) {}

      friend Node operator+(Node x, Node y) { return max(x.s, y.s); }
};

struct Segtree {
      int size;
      vector <Node> tree;

      Segtree(int n) {
            size = 1;
            while (size < n) size <<= 1;
            tree.resize(size << 1, Node());
      }

      Segtree(const vector<int> &a) : Segtree(a.size()) {
            for (int i = 0; i < a.size(); ++i) tree[i + size] = a[i];
            for (int i = size - 1; i > 0; --i) tree[i] = tree[i << 1] + tree[i << 1 | 1];
      }

      int get(int l, int r) {
            l += size;
            r += size - 1;

            Node res = 0;
            while (l <= r) {
                  if (l & 1) res = res + tree[l++].s;
                  if (r % 2 == 0) res = res + tree[r--].s;
                  l /= 2, r /= 2;
            }

            return res.s;
      }

      void set(int i, int v) {
            i += size;
            tree[i].s += v;
            for (i /= 2; i > 0; i /= 2) tree[i] = tree[i * 2] + tree[i * 2 + 1];
      }
};

signed main() {
#ifdef LOCAL
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
#else
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
#endif
      int n, q;
      cin >> n >> q;

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

      vector<int> a(n);
      cin >> a;

      for (int &i: a) i--;

      vector<int> pos(n);
      for (int i = 0; i < n; ++i) pos[a[i]] = i;

      map<int, int> m;
      for (int i = 0; i < g[0].size(); ++i) {
            int u = g[0][i];
            m[u] = i;
      }

      vector<int> b[g[0].size()];
      vector<pair<int, int>> ind(n);
      for (int i = 0; i < g[0].size(); ++i) {
            int v = g[0][i];
            b[i].push_back(v);
            while (!g[v].empty()) {
                  v = g[v][0];
                  b[i].push_back(v);
            }
            for (int j = 0; j < b[i].size(); ++j) {
                  ind[b[i][j]] = {i, j};
            }
      }

      int c = g[0].size();
      vector<int> mn[c];
      for (int i = 0; i < c; ++i) {
            mn[i].push_back(a[b[i][0]]);
            for (int j = 1; j < b[i].size(); ++j) {
                  mn[i].push_back(min(mn[i].back(), a[b[i][j]]));
            }
      }

      vector<int> ans(n, -1e9);
      ans[0] = 0;
      set<pair<int, int>, greater<pair<int, int>>> vals;
      for (int v: g[0]) vals.insert({a[v], v});
      Segtree st(c);
      int all = 1;
      for (int x = n - 1; x >= 0; --x) {
            int u = pos[x];
            if (u == 0) continue;
            auto [i, j] = ind[u];

            if (mn[i][j] != a[u]) continue;

            while (vals.begin()->first > x) {
                  int v = vals.begin()->second;
                  st.set(ind[v].first, 1);
                  all++;
                  vals.erase(vals.begin());
                  if (!g[v].empty()) {
                        vals.insert({mn[ind[v].first][ind[v].second + 1], g[v][0]});
                  }
            }
            ans[u] = all - max(st.get(0, i), st.get(i + 1, c));
      }

      function<void(int)> ddfs = [&](int u) {
            if (ans[u] == -1e9) ans[u] = ans[p[u]] + 1;
            for (int v: g[u]) ddfs(v);
      };
      ddfs(0);
      while (q--) {
            int u;
            cin >> u;
            cout << ans[u - 1] << endl;
      }
}