#include <bits/stdc++.h>
#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define fast_cin() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)

#pragma optimize("O3")
#pragma target("avx2")
using namespace std;

vector<bool> x;
vector<vector<int>> gr;
int ans = 0;

int mod = 998244353;

int p2(int x_, int p) {
    if (p == 0) return 1;
    int res = p2(x_, p/2);
    if (p&1) return res*res%mod*x_%mod;
    return res*res%mod;
}

vector<int> g;
vector<vector<int>> cn;

void dfs(int v, vector<int> &pon) {
    if (x[v])
        pon.push_back(v+1);
    cn[v] = pon;
    for (int u: gr[v]) {
        dfs(u, pon);
    }
    if (x[v])
        pon.pop_back();
}

bool cnn(int v, int c) {
    if (g[v] == c) return true;
    for (int u: gr[v]) {
        if (cnn(u, c)) return true;
    }
    return false;
}

bool dfs2(int v) {
    bool fl1 = false;
    if (g[v] == v+1) fl1 = true;
    int cn = 0;
    for (int u: gr[v]) {
        bool df = dfs2(u);
        if (!df) return false;
        if (x[v]) cn += cnn(u, v+1);
    }
    if (cn > 1) fl1 = true;
    if (x[v]) return fl1;
    return true;
}

void f(int idx) {
    if (idx < 0) {
        if (dfs2(0)) ++ans;
        return;
    }
    for (int &i: cn[idx]) {
        g[idx] = i;
        f(idx-1);
    }
}

signed main() {
    fast_cin();
    int n,k; cin >> n >> k;
    x.resize(n);
    gr.resize(n);
    cn.resize(n);

    for (int i = 0; i < k; ++i) {
        int xx; cin >> xx;
        x[xx-1] = 1;
    }

    for (int i = 1; i < n; ++i) {
        int u; cin >> u;
        gr[u-1].push_back(i);
    }
    g.resize(n);
    vector<int> pon = {0};
    dfs(0, pon);
    f(n-1);

    cout << ans%mod;
}
