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

const ll INF = 1e18;
const ll mod = 998244353;
const ll maxn = 1e6;

vector<vector<ll>> graph(maxn);
vector<ll> tag(maxn);
vector<ll> tin(maxn);
vector<ll> tout(maxn);

ll x;

ll binpow(ll x, ll st) {
    if (st == 0) return 1;
    if (st == 1) return x % mod;
    ll bp = binpow(x, st / 2) % mod;
    if (st % 2 == 0) return bp % mod * bp % mod;
    return bp % mod * bp % mod * x % mod;
}

vector<ll> sz(maxn);
vector<ll> h(maxn);

void dfs(ll v, ll p) {
    sz[v] = 1;
    for (auto u : graph[v]) {
        if (u == p) continue;
        h[u] = h[v] + 1;
        dfs(u, v);
        sz[v] += sz[u];
    }
}

void solve() {
    ll n, k;
    cin >> n >> k;
    cin >> x;
    --x;
    for (ll i = 1; i < n; ++i) {
        ll p;
        cin >> p;
        --p;
        graph[p].emplace_back(i);
        graph[i].emplace_back(p);
    }
    h[0] = 1;
    dfs(0, -1);
    ll ans = binpow(2, sz[x] - 1);
    ans += binpow(2, sz[x] - 1);
    ans %= mod;
    for (ll y : graph[x]) {
        if (h[y] < h[x]) continue;
        ans = (ans - binpow(2, sz[y]) + mod) % mod;
    }
    ans %= mod;
    cout << ans << endl;
}

signed main() {
    ll t = 1;
    while (t--) {
        solve();
    }
}