
#include <bits/stdc++.h>
#define int long long

const int MAXN = 3 * 1e5 + 1;

int tin[MAXN];
int tout[MAXN];
int dp[MAXN];

int T = 0;

void dfs(int v, std::vector<std::vector<int>> &g, int pred = -1)
{
    tin[v] = T++;

    for (int u : g[v])
    {
        if (u != pred)
        {
            dfs(u, g, v);
        }
    }

    tout[v] = T;
}

bool is_pred(int a, int b)
{
    return (tin[a] <= tin[b] && tout[a] >= tout[b]);
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, q;
    std::cin >> n >> q;

    std::vector<std::vector<int>> g(n);
    std::vector<int> pred(n, -1);

    std::vector<int> help(n);

    for (int i = 1; i <= n - 1; i++)
    {
        int p;
        std::cin >> p;
        p--;

        g[p].push_back(i);
        g[i].push_back(p);
        pred[i] = p;

        if (p == 0)
        {
            help[i] = i;
        }
        else
        {
            help[i] = help[p];
        }
    }

    dfs(0, g);

    std::vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> s[i];
        dp[i] = 0;
    }

    std::vector<int> all;
    std::vector<bool> used(n, false);
    std::set<std::pair<int, int>> now;
    int tmp = 0;
    for (int u : g[0])
    {
        now.insert({-s[u], u});
    }
    while (tmp != -1)
    {
        all.push_back(tmp);
        used[tmp] = true;
        if (now.size() == 0)
        {
            break;
        }

        auto th = now.begin()->second;

        now.erase(now.begin());

        for (int u : g[th])
        {
            if (!used[u])
            {
                now.insert({-s[u], u});
            }
        }

        tmp = th;
    }

    std::multiset<int> all1;
    for (int i = 0; i < n; i++)
    {
        all1.insert(0);
    }
    std::vector<int> ans(n);

    for (int i = 0; i < n; i++)
    {
        int now = all[i];
        if (now == 0)
        {
            ans[now] = 0;
            continue;
        }
        all1.erase(all1.find(-dp[help[now]]));
        int max = -*all1.begin();
        ans[i] = i - max;
        dp[help[now]]++;
        all1.insert(-dp[help[now]]);
    }

    while (q--)
    {
        int x;
        std::cin >> x;
        x--;

        std::cout << ans[x] << ' ';
    }
}