#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
//#define int long long

const int mod = 998244353, N = 1e6 + 10;

int sum(int a, int b) {
    if (a + b >= mod) {
        return a + b - mod;
    }
    return a + b;
}

int raz(int a, int b) {
    if (a - b < 0) {
        return a - b + mod;
    }
    return a - b;
}

vector<int> g[N];
int x[N], st[N], st2[N], col[N], pred[N];
vector<int> can[N];
int n, k, ans = 0;

int dfs(int v, int x) {
    if (col[v] == x) {
        return 1;
    }
    for (auto it : g[v]) {
        int y = dfs(it, x);
        if (y) {
            return 1;
        }
    }
    return 0;
}

void rec(int ind) {
    if (ind == n + 1) {
        for (int j = 1; j <= n; ++j) {
            if (x[j] && col[j] != j) {
                int kol = 0;
                for (auto it : g[j]) {
                    kol += dfs(it, j);
                }
                if (kol < 2) {
                    return;
                }
            }
        }
        ans++;
        return;
    }
    for (auto it : can[ind]) {
        col[ind] = it;
        rec(ind + 1);
    }
    col[ind] = -1;
    rec(ind + 1);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    st2[0] = 1;
    for (int i = 1; i < N; ++i) {
        st2[i] = sum(st2[i - 1], st2[i - 1]);
    }
    for (int i = 1; i <= k; ++i) {
        int y;
        cin >> y;
        x[y] = 1;
    }
    for (int i = 2; i <= n; ++i) {
        int j;
        cin >> j;
        g[j].pb(i);
        pred[i] = j;
    }
    for (int i = 1; i <= n; ++i) {
        can[i] = can[pred[i]];
        if (x[i]) {
            can[i].pb(i);
        }
    }
    rec(1);
    cout << ans;
    return 0;
}