#include <bits/stdc++.h>

// #pragma GCC optimize("O3")
// // #pragma GCC optimize("Ofast")
// // #pragma GCC target("unroll_loops")

using ll = long long;
using ld = long double;
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>

//  using namespace __gnu_pbds;
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e18, MAXN = 1e5, mod = 998244353;

int binpow(int a, int b) {
    if (b == 0) {
        return 1;
    }
    int aa = binpow(a, b / 2);
    if (b % 2 == 0) {
        return (aa * aa) % mod;
    }
    return ((aa * aa) % mod * a) % mod;
}

void solve();

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

vector<vector<int> > g;
vector<int> used, cnt, cnt1;
int ans = 1;

void dfs(int u) {
    used[u] = 1;
    if (cnt1[u] != 1) {
        ans *= (cnt[u] + 1);
    }
    for (auto v: g[u]) {
        if (used[v] == 0) {
            cnt[v] += cnt[u];
            dfs(v);
        }
    }
}

void solve() {
    int n, k;
    cin >> n >> k;
    g.resize(n);
    used.resize(n);
    cnt.resize(n);
    cnt1.resize(n);
    for (int i = 0; i < k; i++) {
        int u;
        cin >> u;
        u--;
        cnt[u]++;
        cnt1[u] = 1;
    }

    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
        g[i].push_back(p);
    }

    dfs(0);

    cout << ans;
}
