import sys input = sys.stdin.readline from collections import deque V,E,S,G=list(map(int,input().split())) EDGE=[list(map(int,input().split())) for i in range(E)] for i in range(E): EDGE[i][0]-=1 EDGE[i][1]-=1 ELIST=[[] for i in range(V)] ELIST2=[set() for i in range(V)] for a,b in EDGE: ELIST[a].append(b) ELIST[b].append(a) ELIST2[a].add(b) ELIST2[b].add(a) Q=[] for i in range(V): if len(ELIST2[i])==1: Q.append(i) while Q: x=Q.pop() for to in ELIST2[x]: to2=to ELIST2[x].remove(to2) ELIST2[to2].remove(x) if len(ELIST2[to2])==1: Q.append(to2) DP=[[1<<60,0] for i in range(V)] DP[S-1]=[0,0] Q=deque() Q.append(S-1) while Q: x=Q.popleft() now,m=DP[x] for to in ELIST[x]: if to in ELIST2[x]: if DP[to][0]>now+1: DP[to]=[now+1,m+1] Q.append(to) elif DP[to][0]==now and DP[to][1]now+1: DP[to]=[now+1,m] Q.append(to) elif DP[to][0]==now and DP[to][1]