from collections import deque N,M,S,T = map(int,input().split()) S -= 1 T -= 1 P = list(map(int,input().split())) l = [[] for _ in range(N)] for _ in range(M): a,b = map(int,input().split()) a -= 1 b -= 1 l[a].append(b) l[b].append(a) st = deque([(S,P[S],0)]) X,Y = 0,0 while st: i,x,y = st.popleft() if i == T: X,Y = x,y break for j in l[i]: if P[j] < x: x = P[j] y += 1 st.append((j,x,y)) st = deque([(T,X,Y)]) visited = [False]*N while st: i,x,y = st.popleft() Y = max(Y,y) for j in l[i]: if not visited[j]: visited[j] = True if P[j] < x: x = P[j] y += 1 st.append((j,x,y)) print(Y)