#pragma GCC optimize("O3,unroll-loops")
#include<bits/extc++.h>
#pragma GCC target("avx2,popcnt")

#define all(_a) _a.begin(), _a.end()
#define sz(_a) int32_t(_a.size())
#define ll long long
#define int long long
#define fi first
#define se second
#define deb(_a) cerr << __LINE__ << ' ' << (#_a) << ": " << _a << '\n';

using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto i: v) out << i << ' ';
    return out;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
    for (auto &i: v) in >> i;
    return in;
}

inline void solve();

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

int mod = 998244353;

int power(ll a, int pw) {
    ll ans = 1;
    while (pw) {
        if (pw & 1) {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        pw /= 2;
    }
    return ans;
}

vector<vector<int>> g, fl;
vector<int> b;
vector<bool> used;
int n, k;

bool f = 1;
int dfs(int v) {
    int cnt = 0, res = 0;
    for (auto i: g[v]) {
        int t = dfs(i);
        // deb(t);
        if ((t & (1 << v))) {
            cnt++;
        }
        res = res | t;
    }
    // deb(cnt);
    if (used[v] && cnt <= 1 && b[v] != v) f = 0;
    if (b[v] != -1) res = res | (1 << b[v]);
    return res;
}
int answer = 0;
void rec() {
    if (sz(b) == n) {
        // deb(b);
        f = 1;
        dfs(0);
        answer += f;
        return;
    }
    for (auto i: fl[sz(b)]) {
        b.push_back(i);
        rec();
        b.pop_back();
    }
    b.push_back(-1);
    rec();
    b.pop_back();
}

inline void solve() {
    cin >> n >> k;
    used.resize(n, 0);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        used[x - 1] = 1;
    }
    g.resize(n);
    vector<int> pr(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
        pr[i] = p - 1;
    }
    fl.resize(n);
    pr[0] = -1;
    for (int i = 0; i < n; i++) {
        int x = i;
        while (x != -1) {
            if (used[x]) {
                fl[i].push_back(x);
            }
            x = pr[x];
        }
    }
    rec();
    cout << answer;
}