from scipy.sparse.csgraph import connected_components from scipy.sparse import csr_matrix N, M, S, T = map(int, input().split()) S -= 1 T -= 1 P = tuple(map(int, input().split())) frm, to = [0] * M, [0] * M for i in range(M): a, b = (int(x) - 1 for x in input().split()) frm[i] = a to[i] = b matr = csr_matrix(([1] * M, (frm, to)), shape=(N, N)) p, labels = connected_components(matr, directed=False) ls, ps = labels[S], P[S] st = set() for x, p in zip(labels, P): if x == ls and p < ps: st.add(p) print(len(st))