import heapq n, m, s, t = map(int, input().split()) s -= 1 t -= 1 p = [int(i) for i in input().split()] e = [[] for _ in range(n)] for _ in range(m): a, b = [int(i) - 1 for i in input().split()] e[a].append(b) e[b].append(a) used = [False] * n used[s] = True q = [(-p[s], s)] min_p = 10**10 ans = -1 while q: i, ind = heapq.heappop(q) i *= -1 if i < min_p: min_p = i ans += 1 for j in e[ind]: if not used[j]: used[j] = True heapq.heappush(q, (-p[j], j)) print(ans)