#include using namespace std; using ll = long long; using pint = pair; #pragma region UnionFind #define UNIONFIND class UnionFind{ private: vector data; public: UnionFind(int n) : data(n,-1) {} int root(int i) { return data[i] < 0 ? i : data[i] = root(data[i]); } int size(int i) { return -data[root(i)]; } bool same(int x, int y) {return root(x) == root(y); } bool connected() {return size(0) == (int)data.size(); } bool unit(int i,int j){ i = root(i); j = root(j); if(i != j){ data[i] += data[j]; data[j] = i; } return i != j; } }; #pragma endregion // #include"debug.hpp" int main() { int n, m, s, t; cin >> n >> m >> s >> t; s--,t--; vector p(n); vector> hen(n); vector> edge; for(auto &i : p) cin >> i; UnionFind uf(n); for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--,v--; edge.emplace_back(u, v, p[v]); edge.emplace_back(v, u, p[u]); } sort(edge.begin(), edge.end(), [&](tuple& x, tuple& y){return get<2>(x) > get<2>(y);}); int e = edge.size(); // print(edge); int sum = 0; set st; st.insert(s); int X = p[s]; for(int i = 0; i < e; i++) { auto [from, to, cost] = edge[i]; // if(uf.same(from, to)) continue; if(uf.same(from, s) == 1) { if(!st.count(to) && cost < X)sum++; st.insert(to); } uf.unit(from, to); X = min(cost, X); } cout << sum << endl; }