#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

#define rs resize
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

typedef long double ld;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<typename T>
istream &operator >>(istream &in, pair<T, T> &a) {
    in >> a.ff >> a.ss;
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, pair<T, T> &a) {
    out << a.ff << " " << a.ss;
    return out;
}

template<typename T>
istream &operator >>(istream &in, vector<T> &a) {
    for (auto &i : a) in >> i;
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, vector<T> &a) {
    for (auto i : a) cout << i << " ";
    return out;
}

const int maxn = 3e5 + 10;
vector<int> g[maxn];
int c[maxn], d[maxn], nb[maxn];
vector<pii> sp[maxn];
void dfs_f(int v, int p, int pr) {
    d[v] = d[p] + 1;

    nb[v] = nb[pr];
    sp[pr].pb({c[v], v});

    for (auto i : g[v]) {
        if (i != p) {
            dfs_f(i, v, pr);
        }
    }
}

int ans[maxn], cnt[maxn];
void solve() {
    int n, q; cin >> n >> q;
    for (int i = 1; i <= n - 1; i++) {
        int a; cin >> a;
        a--;

        g[a].pb(i); g[i].pb(a);
    }

    for (auto i : g[0]) {
        dfs_f(i, 0, i);
    }

    set<pii> s1;
    for (auto i : g[0]) s1.insert(sp[i][0]);

    ans[0] = 0;

    int sm = 0;
    set<pii> mx;
    for (auto i : g[0]) mx.insert({0, i});
    while (!s1.empty()) {
        auto cur = s1.end(); cur--;
        auto [a, b] = *cur; s1.erase(cur);

        mx.erase({cnt[nb[b]], nb[b]});
        ans[b] = sm - (*mx.rbegin()).ff;
        if (sz(sp[nb[b]]) > d[b]) s1.insert({sp[nb[b]][d[b]]});
        sm++;
        cnt[nb[b]]++;
        mx.insert({cnt[nb[b]], nb[b]});
    }

    for (int i = 0; i < q; i++) {
        int a; cin >> a;
        a--;

        cout << ans[a] << "\n";
    }
}

int32_t main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#endif
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    double tim = clock();
#endif

    int tests = 1;
    //cin >> tests;
    while (tests--) {
        solve();
#ifdef LOCAL
        cout << "-------------------\n";
#endif
    }

#ifdef LOCAL
    cout << (double)(clock() - tim) / CLOCKS_PER_SEC;
#endif
}
