#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#endif

#include <bits/extc++.h>

using namespace std;

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

vector <vector <int>> g;
vector <int> sz;

void dfs(int v) {
    sz[v] = 1;
    for (int u : g[v]) {
        dfs(u);
        sz[v] += sz[u];
    }
}

const int mod = 998244353;

int pw(int a, int m) {
    int ans = 1;
    while (m) {
        if (m & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        m >>= 1;
    }
    return ans;
}

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr), ios_base::sync_with_stdio(false);
#endif
    int n,k;
    cin >> n >> k;
    g.resize(n + 1);
    sz.resize(n + 1);
    int x;
    cin >> x;
    for (int u = 2; u <= n; u++) {
        int v;
        cin >> v;
        g[v].push_back(u);
    }
    dfs(1);
    int ans = pw(2, sz[x] - 1), sum = 0;
    for (int u : g[x]) sum += sz[u];
    for (int u : g[x]) {
        sum -= sz[u];
        ans += ((sz[u] * (sz[u] + 1) / 2) % mod * (pw(2, sum) - 1)) % mod;
    }
    cout << ans;
    return 0;
}
