#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;
using ll = long long;

#define int long long
#define all(x) x.begin(), x.end()

const int inf = 1e18;
const int mod = 998244353;

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

struct segTree {
    vector<int> t;
    int n;

    segTree(vector<int>& a) {
        n = a.size();
        t.assign(2 * n, 0);
        for (int i = 0; i < n; i++) t[i + n] = a[i];
        for (int i = n - 1; i >= 0; i--) t[i] = max(t[i << 1], t[(i << 1) | 1]);
    }

    int get(int l, int r) {
        int ans = -inf;
        l += n, r += n;
        while (l < r) {
            if (l & 1) ans = max(ans, t[l++]);
            if (r & 1) ans = max(ans, t[--r]);
            l >>= 1, r >>= 1;
        }
        return ans;
    }

    void upd(int i, int x) {
        i += n, t[i] = x, i >>= 1;
        while (i) t[i] = max(t[i << 1], t[(i << 1) | 1]), i >>= 1;
    }
};

struct Fen {
    vector<int> t;
    int n;

    Fen(int x) {n = x;t.assign(n + 1, 0);}
    int sum(int r) {int ans = 0;for (; r > 0; r -= r & -r) ans += t[r];return ans;}
    int get(int l, int r) {l++, r++;return sum(r) - sum(l - 1);}
    void upd(int i, int x) {i++;for (; i <= n; i += i & -i) t[i] += x;}
};

vector<vector<int>> g;
vector<int> sz;
int x;
vector<int> l;

void dfs(int v, int p) {
    for (int& u : g[v]) {
        if (u != p) {
            dfs(u, v);
            sz[v] += sz[u];
            if (x == v) l.push_back(sz[u]);
        }
    }
}

int bpow(int a, int n) {
    int res = 1;

    while (n) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }

    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;

    g.assign(n, vector<int> ());
    sz.assign(n, 1);
    cin >> x;
    x--;

    for (int i = 1; i < n; i++) {
        int y;
        cin >> y;
        y--;
        g[y].push_back(i);
        g[i].push_back(y);
    }

    dfs(0, 0);
    int ans = bpow(2, sz[x] - 1);
    int res = bpow(2, sz[x] - 1);
    for (int i = 0; i < l.size(); i++) {
        int y = l[i];
        int sum = bpow(2, y);
        sum--;
        sum %= mod;
        sum += mod;
        sum %= mod;
        res -= sum;
        res %= mod;
        res += mod;
        res %= mod;
    }
    res--;
    res %= mod;
    res += mod;
    res %= mod;
    ans += res;
    ans %= mod;
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif

    int t = 1;
    // cin >> t;

    while (t--) solve();
}