#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll mod = 998244353;
const ll inf = 1e17;

vector<vector<ll>> G;
vector<ll> sz;
void dfs(ll v, ll p) {
    for (ll u : G[v]) {
        if (u == p) continue;
        dfs(u, v);
        sz[v] += sz[u];
    }
}

ll binpow(ll a, ll b) {
    if (!b) return 1;
    if (b % 2 == 1) {
        return a * binpow(a, b - 1) % mod;
    }
    ll x = binpow(a, b / 2);
    return x * x % mod;
}

void solve() {
    ll n, k; cin >> n >> k;
    vector<ll> X(k);
    for (ll i = 0; i < k; ++i) cin >> X[i];
    G.assign(n + 1, {});
    vector<ll> P(n + 1, 0);
    for (ll i = 2; i <= n; ++i) {
        ll p; cin >> p;
        P[i] = p;
        G[p].push_back(i);
        G[i].push_back(p);
    }
    sort(X.begin(), X.end());
    ll ans = binpow(2ll, (n - X[0] - k + 1));
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}