#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <algorithm>
#include <chrono>
#include <random>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define its(a) a.begin(), a.end()
#define scan(a) {for (int i = 0; i < a.size(); ++i) cin >> a[i];}
constexpr ll INFLL = 1e18 + 130;
constexpr int INFINT = 1e9 + 13;
constexpr int MAXN = 1e6;
constexpr int LOGN = 18;
constexpr int M = 998'244'353;
std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());

int binPow(int a, int n) {
	if (!n) return 1;
	if (n & 1) return 1ll * a * binPow(a, n - 1) % M;
	return binPow(1ll * a * a % M, n / 2);
}

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

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

void solve() {
	int n, k; cin >> n >> k;
	g.resize(n);
	sz.resize(n);
	x.resize(k);
	for (int i = 1; i < n; ++i) {
		int p; cin >> p; p--;
		g[p].push_back(i);
	}
	int x; cin >> x; x--;
	dfs(0);
	ll ans = binPow(2, sz[x]) - 1;
	if (ans < 0) ans += M;
	for (int u : g[x]) {
		ans -= ((binPow(2, sz[u]) - 1) % M + M) % M;
		ans = (ans % M + M) % M;
	}
	cout << ans;
}

int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	solve();
}

/*
*/