#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const ll mod = 998244353;
ll x;

void dfs(ll v, vector<bool> &used, vector<bool> &is, vector<ll> &p) {
    used[v] = 1;
    if (v == x) is[v] = 1;
    if (v == 0) return;
    if (!used[p[v]]) dfs(p[v], used, is, p);
    if (is[p[v]]) is[v] = 1;
}

ll calc(ll v, vector<vector<ll>> &par, vector<bool> &is, vector<ll> &k) {
    if (is[v]) k[v]++;
    for (ll u : par[v]) {
        if (is[u] && !k[u]) {
            calc(u, par, is, k);
        }
        k[v] += k[u];
    }
}

int main() {
    ll n, k;
    cin >> n >> k;
    cin >> x;
    x--;
    vector<ll> p(n);
    for (ll i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    vector<bool> used(n), is(n);
    for (ll i = 0; i < n; i++) {
        if (!used[i]) dfs(i, used, is, p);
    }
    ll cnt = 0;
    for (ll i : is) {
        cnt += (i != 0);
    }
    vector<ll> pows(n + 1);
    pows[0] = 1;
    for (ll i = 1; i <= n; i++) {
        pows[i] = (pows[i - 1] * 2) % mod;
    }
    ll res = pows[cnt - 1];
    vector<vector<ll>> par(n);
    for (ll i = 1; i < n; i++) {
        par[p[i]].push_back(i);
    }
    vector<ll> kk(n), c;
return 0;
    calc(x, par, is, kk);
    for (ll i : par[x]) {
        // cout << i << ' ' << kk[i] << '\n';
        if (kk[i]) c.push_back(kk[i]);
    }
    // cout << res << '\n';
    sort(c.begin(), c.end());
    ll sum = c[0];
    for (ll i = 1; i < (ll) c.size(); i++) {
        // cout << sum << ' ' << c[i] << '\n';
        res = (res + (((pows[sum] + mod - 1) % mod) * (pows[c[i]] - 1 + mod))) % mod;
        sum += c[i];
        // cout << res << '\n';
    }
    cout << res << '\n';
}


