#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pp = pair<int, int>;
using ld = long double;

template <typename T>
istream &operator>>(istream &s, vector<T> &a)
{
    for (T &el : a)
    {
        s >> el;
    }
    return s;
}

template <typename T>
ostream &operator<<(ostream &s, vector<T> &a)
{
    for (T el : a)
    {
        s << el << ' ';
    }
    s << '\n';
    return s;
}

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<int> p(n, -1), s(n), tin(n), tout(n);
    vector<vector<int>> graph(n);
    for (int i = 1; i < n; i++)
    {
        cin >> p[i];
        p[i]--;
        graph[p[i]].push_back(i);
    }
    int timer = 0;
    function<void(int)> dfs = [&](int v)
    {
        tin[v] = timer;
        timer++;
        for (int to : graph[v])
        {
            dfs(to);
        }
        tout[v] = timer;
        timer++;
    };
    dfs(0);
    function<bool(int, int)> is_anc = [&](int a, int b)
    {
        return tin[a] <= tin[b] && tout[b] <= tout[a];
    };
    cin >> s;
    vector<int> order;
    set<pp> choice;
    choice.emplace(s[0], 0);
    while (!choice.empty())
    {
        int v = prev(choice.end())->second;
        choice.erase(prev(choice.end()));
        order.push_back(v);
        for (int to : graph[v])
        {
            choice.emplace(s[to], to);
        }
    }
    vector<int> cnt(n), ans(n);
    for (int i = n - 1; i >= 0; i--)
    {
        int nd = order[i];
        cnt[nd]++;
        for (int to : graph[nd])
        {
            cnt[nd] += cnt[to];
        }
    }
    choice.clear();
    for (int i = 0; i < n; i++)
    {
        choice.emplace(cnt[order[i]], order[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {
        auto it = prev(choice.end());
        int mx = 0;
        int nd = order[i];
        while (true)
        {
            if (!is_anc(it->second, nd))
            {
                mx = it->first;
                break;
            }
            if (it == choice.begin())
            {
                break;
            }
            it = prev(it);
        }
        ans[nd] = i - mx;
        //
        for (int v = nd; v != -1; v = p[v])
        {
            choice.erase({cnt[v], v});
            cnt[v]--;
            if (v != nd)
            {
                choice.emplace(cnt[v], v);
            }
        }
    }
    while (q--)
    {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
}

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