#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename t>
istream& operator>>(istream &in, vector<t> &a){
    for (auto &el : a){
        in >> el;
    }
    return in;
}

template <typename t>
ostream& operator<<(ostream &out, vector<t> &a){
    for (auto &el : a){
        out << el << " ";
    }
    return out;
}

const int maxn = 1e6 + 10;
vector<int> g[maxn];
int point[maxn];
int ans = 0;
const int mod = 998244353;
int fact[maxn], ofact[maxn];
int sz[maxn];



int pw(int a, int p){
    int ans = 1;
    for (; p > 0; p /= 2){
        if (p % 2) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans;
}

int o(int a){
    return pw(a, mod - 2);
}

int C(int n, int k){
    if (k < 0 || k > n) return 0;
    return fact[n] * ofact[k] % mod * ofact[n - k] % mod;
}


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

const int maxn1 = 10;

int dp[maxn1][maxn1];

void add(int &x, int y){
    x += y;
    if (x >= mod) x -= mod;
}


void dfs1(int u){
    for (int v : g[u]){
        dfs1(v);
    }
    for (int v : g[u]){
        for (int cnt = 0; cnt <= sz[v]; ++cnt){
            for (int cnt1 = sz[u]; cnt1 >= cnt; --cnt1){
                add(dp[u][cnt1], dp[u][cnt1 - cnt] * dp[v][cnt]);
            }
        }
    }
}

int pr[maxn1];
vector<int> _pr[maxn1];
vector<int> now;
int n;


int check(){
    vector<int> from(n, -1);
    vector<int> ok(n);
    for (int u = 0; u < n; ++u){
        if (now[u] == -1) continue;
        int v = u;
        if (now[u] == u) {
            ok[u] = 1;
            continue;
        }
        while (pr[v] != now[u]){
            v = pr[v];
        }
        if (from[now[u]] == -1) from[now[u]] = v;
        else ok[now[u]] = 1;
    }
    int _ok = 1;
    for (int i = 0; i < n; ++i){
        if (!point[i]) continue;
        _ok &= ok[i];
    }
    return _ok;
}


void rec(int i){
    if (i == n){
        if (check()) ++ans;
    } else{
        for (auto u : _pr[i]){
            now.pb(u);
            rec(i + 1);
            now.pop_back();
        }
    }
}




void solve(){
    int k;
    cin >> n >> k;
    vector<int> x(k);
    for (int i = 0; i < k; ++i){
        cin >> x[i];
        x[i]--;
        point[x[i]] = 1;
    }
    for (int i = 1; i < n; ++i){
        int p;
        cin >> p;
        p--;
        g[p].pb(i);
        pr[i] = p;
    }
    for (int i = 0; i < n; ++i){
        int u = i;
        _pr[i].pb(-1);
        while (u != 0){
            if (point[u]) _pr[i].pb(u);
            u = pr[u];
        }
        if (point[u]) _pr[i].pb(u);
    }
    rec(0);
    cout << ans << endl;
    return;
    dfs(0);
    int cnt = sz[x[0]] - 1;
    ans = pw(2, cnt);
    ans += pw(2, cnt) - 1;
    for (int v : g[x[0]]){
        ans -= pw(2, sz[v]) - 1;
    }
    ans = (ans % mod + mod) % mod;
    cout << ans << endl;
}


signed main(){
    fact[0] = 1;
    for (int i = 1; i < maxn; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }
    ofact[maxn - 1] = o(fact[maxn - 1]);
    for (int i = maxn - 2; i >= 0; --i){
        ofact[i] = ofact[i + 1] * (i + 1) % mod;
    }
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}