#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

#define int long long

int32_t main() {
    int n, k; cin >> n >> k;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int v; cin >> v;
        g[v - 1].push_back(i + 1);
    }

    int v1 = k - 1;
    vector<int> s(n + 1);
    auto dfs = [&](auto &&dfs, auto v) -> int {
        int sz = 1;
        for (auto &u : g[v]) {
            sz += dfs(dfs, u);
        }
        s[v] = sz;
        return sz;
    };
    int rs = 1;
    dfs(dfs, v1);
    for (auto &u : g[v1]) rs *= (s[u] + 1), rs %= MOD; if (g[v1].size()) rs++;
    cout << rs << '\n';
    return 0;
}