#include <iostream>
#include <vector>
#include <algorithm>
#include<set>
#include <cinttypes>
#include <string>
#include <map>

using namespace std;

vector<int64_t> dfs(vector<vector<int64_t> >& a, vector<bool>& b, int64_t v) {
    vector<int64_t> ans(a.size()+1, 0);
    if (b[v] == false) {
        ans[1] = 1;
    } else {
        ans[0] = 0;
    }
    for (auto el : a[v]) {
        auto now = dfs(a, b, el);
        auto l = ans;
        for (int i = 0; i <= a.size(); i++) {
            ans[i] = 0;
            for (int j = 0; i + j <= a.size(); j++) {
                ans[i + j] += l[i]*now[j];
            }
        }
    }
    if (b[v]) {
        for (int i = a.size()-1; i >= 0; i--) {
            ans[i] += ans[i+1];
        }
    }
    return ans;
}

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<vector<int64_t> > a(n);
    for (int i = 1; i < n; i++) {
        int64_t x;
        cin >> x;
        x--;
        a[x].push_back(i);
    }
    vector<bool> b(n, false);
    for (int i = 0; i < k; i++) {
        int64_t x;
        cin >> x;
        x--;
        b[x] = true;
    }
    auto now = dfs(a, b, 0);
    int64_t ans = 0;
    for (auto el : now) {
        ans += el;
    }
    cout << ans << '\n';
    return 0;
}
