Time limit
2s
Memory limit
128 MB
Taehui wants to get away from work and go on vacation. After some research, Taehui chooses N cities to visit. At first, it seemed that flights would be enough to plan the trip, but not every pair of cities is connected by a flight.
There are M flight routes in total, and each route can be used in only one direction. Taehui will start in city S and finish the trip in city T.
Given the cities and flight routes, find the maximum number of distinct cities that can be visited during a trip from city S to city T. A city is counted only once even if it is visited multiple times. Cities may be revisited any number of times, and the same flight route may also be used multiple times.
The first line contains four integers N, M, S, and T. (1≤N≤10000, 1≤M≤100000, 1≤S,T≤N)
Each of the next M lines contains two distinct integers A and B describing one flight route. (1≤A,B≤N, A=B) This means there is a route from city A to city B.
Print the maximum number of distinct cities that can be visited. If it is impossible to travel from city S to city T, print 0.