#include <bits/stdc++.h>

using namespace std;

// #define int long long
using ld = long double;
using ll = long long;
using pii = pair<int, int>;

int n, q;
vector<vector<int>> g;
vector<int> ans;
vector<int> s;
vector<int> ti;
vector<int> p2;

// вершина => количество
vector<int> tree;

void mod(int v, int l, int r, int i)
{
    if (l == r - 1)
    {
        assert(l == i);
        tree[v]++;
        return;
    }
    int m = (l + r) / 2;
    if (i < m)
    {
        mod(v * 2 + 1, l, m, i);
    }
    else
    {
        mod(v * 2 + 2, m, r, i);
    }
    tree[v] = max(tree[v * 2 + 1], tree[v * 2 + 2]);
}

int get(int v, int l, int r, int L, int R)
{
    if (R <= l || r <= L)
        return 0;
    if (L <= l && r <= R)
        return tree[v];
    int m = (l + r) / 2;
    return max(get(v * 2 + 1, l, m, L, R), get(v * 2 + 2, m, r, L, R));
}

void dfs(int v, int pp2)
{
    p2[v] = pp2;
    for (const auto &u : g[v])
    {
        dfs(u, pp2);
    }
}

bool cmp(const int &a, const int &b)
{
    return s[a] < s[b];
}

void solve()
{
    cin >> n >> q;
    g.resize(n);
    ans.resize(n);
    s.resize(n);
    ti.resize(n, -1);
    tree.resize(n * 4, 0);
    // TODO : ASSERT
    p2.resize(n);

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

    int ct = 0;
    int cur = 0;
    set<pii> av;
    while (true)
    {
        assert(ti[cur] == -1);
        ti[cur] = ct;
        for (const auto &u : g[cur])
        {
            av.insert({s[u], u});
        }
        if (av.empty())
            break;
        auto it = av.rbegin();
        cur = it->second;
        av.erase({s[cur], cur});
        ++ct;
    }

    for (const auto &u : g[0])
    {
        dfs(u, u);
    }

    vector<int> arr(n);
    for (int i = 0; i < n; ++i)
    {
        arr[i] = i;
    }
    sort(arr.begin(), arr.end(), cmp);

    for (const auto &v : arr)
    {
        ans[v] = max(get(0, 0, n, 0, v), get(0, 0, n, v + 1, n));
        mod(0, 0, n, p2[v]);
    }

    for (int qq = 0; qq < q; ++qq)
    {
        int v;
        cin >> v;
        --v;
        int res = ti[v] - ans[v];
        cout << res << ' ';
    }
    cout << '\n';
}

signed main()
{
#ifdef ROMALOCAL
    freopen("in.txt", "r", stdin);
#endif

    cin.tie(0);
    ios::sync_with_stdio(0);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}