#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()

const ll MOD = 998244353;

struct mint {
    ll x;

    mint(ll s = 0) {
        x = s;
    }

    mint operator+(mint other) {
        mint res;
        res.x = x + other.x;
        if (res.x > MOD) {
            res.x -= MOD;
        }
        return res;
    }

    mint operator-(mint other) {
        mint res;
        res.x = x - other.x;
        if (res.x < 0) {
            res.x += MOD;
        }
        return res;
    }

    mint operator*(mint other) {
        mint res;
        res.x = x * other.x;
        res.x %= MOD;
        return res;
    }

    mint binpow(ll n) {
        if (n == 0) return 1;
        if (n == 1) {
            return (*this);
        }
        if (n % 2 == 0) {
            mint lr = binpow(n / 2);
            return lr * lr;
        }
        return (*this) * binpow(n - 1);
    }
};


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

    ll n;
    cin >> n;
    ll k;
    cin >> k;

    ll x;
    cin >> x;
    x--;

    vector<ll> p(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }

    vector<ll> dp(n);
    ll cus = 0;
    vector<ll> pom;
    for (int i = n - 1; i >= 0; --i) {
        if (i == x) {
            break;
        }
        dp[i] += 1;
        dp[p[i]] += dp[i];
        if (p[i] == x) {
            cus++;
            pom.push_back(dp[i]);
        }
    }

    mint ans = mint(2).binpow(dp[x]);
    mint lr = 1;
    for (int i = 0; i < pom.size(); ++i) {
        lr = lr * mint(2).binpow(pom[i]);
    }
    lr = lr - mint(pom.size()) - mint(1);
    cout << (ans + lr).x;
}
