#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define vc vector
#define db double
#define str string
#define its(a) (a).begin(), (a).end()
#define itsr(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define tstr to_string
#define scan(a) for (auto &_i:a) cin >> _i;

const ll MOD = 998244353;

void solve() {
	/*vc<ll> tr;
	auto get = [&](auto get, int v, int l, int r, int lq, int rq) -> ll {
		if (lq <= l and r <= rq) return tr[v];
		if (rq <= l or r <= lq) return 0;
		int mid = (r + l) >> 1;
		return get(get, 2 * v + 1, l, mid, lq, rq) + get(get, 2 * v + 2, mid, r, lq, rq);
	};
	auto build = [&](auto build, int v, int l, int r) -> void {
		if (r - l == 1) {
			tr[v] = a[l];
			return;
		}
		int mid = (r + l) >> 1;
		build(build, 2 * v + 1, l, mid);
		build(build, 2 * v + 2, mid, r);
		tr[v] = tr[2 * v + 1] + tr[2 * v + 2];
	};
	auto st = [&](auto st, int v, int l, int r, int e, int x) -> void {
		if (r - l == 1) {
			tr[v] = x;
			return;
		}
		int mid = (r + l) >> 1;
		if (e < mid) st(st, 2 * v + 1, l, mid, e, x);
		else st(st, 2 * v + 2, mid, r, e, x);
		tr[v] = tr[2 * v + 1] + tr[2 * v + 2];
	};*/

	ll n, k; cin >> n >> k;
	vc<ll> p(k); scan(p);

	vc<ll> mark(n);
	for (int i = 0; i < k; ++i) mark[p[i]] = 1;

	vc<vc<ll>> g(n);
	for (int i = 1; i < n; ++i) {

		ll u; cin >> u;
		--u;
		g[u].push_back(i);
	}

	vc<ll> trs(n);
	ll ans = 0;
	auto dfs = [&](auto dfs, int u) -> void {
		trs[u] = 1;
		
		for (auto v : g[u]) {
			dfs(dfs, v);
			trs[u] += trs[v];
		}
		if (mark[u]) {
			ans = 2;
			for (auto v : g[u]) {
				ans *= (trs[v] + 1);
				ans %= MOD;
			}
			ans = (ans - trs[u] + MOD) % MOD;
			if (sz(g[u]) == 0) ans = 1;

		}
	};
	dfs(dfs, 0);
	cout << ans;
}

int main()
{
	cin.tie(0)->sync_with_stdio(0);

	ll _t = 1;
	//cin >> _t;
	while (_t--)
		solve();
}
