//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ld long double
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define coutp cout << "       "
#define cont continue
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
istream& operator>> (istream& in, pair<T, T>& a) {
    in >> a.F >> a.S;
    return in;
}

template<typename T>
ostream& operator<< (ostream& os, pair<T, T>& a) {
    os << a.F << " " << a.S;
    return os;
}

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

template<typename T>
ostream& operator<< (ostream& os, vector<T>& a) {
    for (auto& x : a) {
        os << x << " ";
    }
    return os;
}

constexpr int inf = 2e18, mod = 998244353;
constexpr ld eps = 1e-9;

int add(int a, int b) {
    return (a + b) % mod;
}

int mul(int a, int b) {
    return (a * b) % mod;
}

int fast_pow(int a, int k) {
    if (k == 0) {
        return 1;
    }
    int q = fast_pow(a, k / 2);
    q = mul(q, q);
    if (k % 2 == 1) {
        q = mul(q, a);
    }
    return q;
}

int mi(int a, int b) {
    return (a + mod - b) % mod;
}

vector<vector<int>> g, g2;
int cnt2 = 0, cnt = 0;

void dfs(int v, int st) {
    cnt2++;
   // if (v != st) cout << v << " " << g[v][0] << endl;
    if (v != st and g[v][0] == st) {
        cnt++;
    }
    for (auto to : g2[v]) {
       // coutp << v << " " << to << endl;
        dfs(to, st);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int multitest = 1; //cin >> multitest;
    while (multitest--) {
        int n, k; cin >> n >> k;
        g.resize(n);
        g2.resize(n);
        vector<int> b(k); cin >> b;
        for (int i = 1; i < n; i++) {
            int x; cin >> x; x--;
            g[i].pb(x);
            g2[x].pb(i);
        }
        for (auto& x : b) {
            x--;
        }
        dfs(b[0], b[0]);
        cnt2--;
        //cout << cnt2 << " " << cnt << endl;
        int ans = fast_pow(2, cnt2);
        ans = add(ans, mi(fast_pow(2, cnt), cnt));
        cout << mi(ans, 1);
    }
    return 0;
}

/*

*/
