import sys input = sys.stdin.readline from heapq import * from collections import defaultdict class Graph: def __init__(self, N, M=-1): self.V = N if M>=0: self.E = M self.edge = [[] for _ in range(self.V)] self.edge_rev = [[] for _ in range(self.V)] self.order = [] self.to = [0]*self.V self.visited = [False]*self.V self.dp = [0]*self.V def add_edges(self, ind=1, bi=False, rev=False): for i in range(self.E): a,b = map(int, input().split()) a -= ind; b -= ind self.edge[a].append(b) if rev: self.edge_rev[b].append(a) if not bi: self.to[b] += 1 if bi: self.edge[b].append(a) def add_edge(self, a, b, dist=-1, bi=False, rev=False): if dist>=0: self.edge[a].append((dist, b)) if rev: self.edge_rev[b].append((dist, a)) if bi: self.edge[b].append((dist, a)) else: self.edge[a].append(b) if rev: self.edge_rev[b].append(a) if bi: self.edge[b].append(a) if not bi: self.to[b] += 1 def bfs(self, start): self.visited[start] = True d = [(-P[start], start)] heapify(d) dic = defaultdict(lambda: False) ans = 0 while len(d)>0: p,v = heappop(d) for w in self.edge[v]: if not self.visited[w]: if P[w]<-p: if dic[P[w]]==False: ans += 1 dic[P[w]] = True else: P[w] = -p self.visited[w] = True heappush(d, (-P[w],w)) return ans N, M, S, T = map(int, input().split()) P = list(map(int, input().split())) G = Graph(N,M) G.add_edges(bi=True) print(G.bfs(S-1))