#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; vector P(N); for(auto &p : P) cin >> p; vector> Graph(N); for(int i=0; i> u >> v; u--; v--; Graph.at(u).insert(v); Graph.at(v).insert(u); } vector NG(N); vector check(M); for(auto &c : check) cin >> c,c--,NG.at(c) = true; priority_queue> Q; for(int i=0; i next; for(auto pos : check) for(auto to : Graph.at(pos)) if(!NG.at(to)) NG.at(to) = true,next.push_back(to); swap(check,next); } cout << answer << endl; }