#include <bits/stdc++.h>

using namespace std;

#define sll __int128_t
#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define size(x) (int)(x).size()

const int MOD = 998244353, MAXN = 2002, inf = 1e9;

int add(int a, int b) {
    if (a + b >= MOD) {
        return a + b - MOD;
    }
    return a + b;
}

int sub(int a, int b) {
    if (a - b < 0) {
        return a - b + MOD;
    }
    return a - b;
}

int mult(int a, int b) {
    return ((ll)a * b) % MOD;
}

int kv(int a) {
    return ((ll)a * a) % MOD;
}

int fast_pow(int x, int a) {
    if (a == 0) return 1;
    if (a == 1) return x;
    if (a & 1) return mult(x, fast_pow(x, a - 1));
    return kv(fast_pow(x, a / 2));
}

vector<int> g[MAXN];
int child[MAXN], used[MAXN], sp[MAXN], dp[MAXN][MAXN][2];
int dp2[MAXN][2];

void dfs(int v) {
    child[v] = 1;
    sp[v] = used[v];
    dp[v][0][0] = 1;
    dp[v][1][1] = 1;
    for (auto to : g[v]) {
        dfs(to);
        for (int i = 0; i <= child[v]; i++) {
            for (int t1 = 0; t1 <= 1; t1++) {
                for (int j = sp[to]; j <= child[to]; j++) {
                    for (int t2 = 0; t2 <= 1; t2++) {
                        dp2[i + j][i > 0 && j > 0 || t1] = add(dp2[i + j][i > 0 && j > 0 || t1], mult(dp[v][i][t1], dp[to][j][t2]));
                    }
                }
            }
        }
        child[v] += child[to];
        sp[v] += sp[to];
        for (int i = 0; i <= child[v]; i++) {
            dp[v][i][0] = dp2[i][0];
            dp[v][i][1] = dp2[i][1];
            dp2[i][0] = dp2[i][1] = 0;
        }
    }
}

int get(int v, int k) {
    for (auto to : g[v]) {
        if (sp[to] == k) {
            return get(to, k);
        }
    }
    return v;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> x(k);
    for (int i = 0; i < k; i++) {
        cin >> x[i]; x[i]--;
        used[x[i]] = 1;
    }
    for (int i = 1; i < n; i++) {
        int p; cin >> p; p--;
        g[p].push_back(i);
    }
    dfs(0);
    int ans = 0;
    int st = get(0, k);
    for (int i = sp[st]; i <= child[st]; i++) {
        ans = add(ans, dp[st][i][1]);
    }
    // cout << st << endl;
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int ttt = 1;
    //cin >> ttt;
    while (ttt--) {
        solve();
    }
}