#include <bits/stdc++.h>

using namespace std;

const int N = 15;
vector<int> penis[N];
vector<int> g[N];
int x[N];
int nn;
int lca[N][N];
int par[N][N];
int p2[N];

void dfs(int v, int p, vector<int> cur,vector<int> cur2) {
    p2[v] = p;
    cur2.emplace_back(v);
    if(x[v]) {
        cur.emplace_back(v);
    }
    penis[v] = cur;
    for(auto u : cur2) {
        par[v][u] = 1;
    }
    for(auto u : g[v]) {
        if(u != p) {
            dfs(u,v,cur,cur2);
        }
    }
}

int res = 0;

void rec(int pos, vector<int> xx) {
    if(pos == nn) {
        vector<vector<int>> p(nn);
        for(int i = 0; i < nn; ++i) {
            if(xx[i] == -1) {
                continue;
            }
            p[xx[i]].emplace_back(i);
        }
        bool ok = true;
        for(int i = 0; i < nn; ++i) {
            if(x[i] && p[i].size() == 0) {
                ok = false;
            }
            if(p[i].size()) {
                int v = p[i][0];
                for(int j = 1; j < p[i].size(); ++j) {
                    v = lca[v][p[i][j]];
                }
                ok &= (v == i);
            }
        }
        res += ok;
        return;
    }
    for(auto u : penis[pos]) {
        xx.emplace_back(u);
        rec(pos+1, xx);
        xx.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n,k;
    cin >> n >> k;
    nn = n;    
    for(int i = 0; i < k; ++i) {
        int cur;
        cin >> cur;
        cur--;
        x[cur] = 1;
    }
    for(int i = 1; i < n; ++i) {
        int v;
        cin >> v;
        v--;
        g[v].emplace_back(i);
        g[i].emplace_back(v);
    }                
    dfs(0, -1,vector<int>(), vector<int>());
    for(int i = 0; i < n; ++i) {
        penis[i].emplace_back(-1);
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            int v = i;
            int u = j;
            while(!par[u][v]) {
                v = p2[v];
            }
            lca[i][j] = v;
        }
    }
    rec(0, vector<int>());        
    cout << res << '\n';
    return 0;
}