cho.sh
Notes
Loading...

Planning a Trip

Time limit

2s

Memory limit

128 MB

Problem

Taehui wants to get away from work and go on vacation. After some research, Taehui chooses NNN 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 MMM flight routes in total, and each route can be used in only one direction. Taehui will start in city SSS and finish the trip in city TTT.

Given the cities and flight routes, find the maximum number of distinct cities that can be visited during a trip from city SSS to city TTT. 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.

Input

The first line contains four integers NNN, MMM, SSS, and TTT. (1≤N≤10 000, 1≤M≤100 000, 1≤S,T≤N)(1 \le N \le 10\,000,\ 1 \le M \le 100\,000,\ 1 \le S,T \le N)(1≤N≤10000, 1≤M≤100000, 1≤S,T≤N)

Each of the next MMM lines contains two distinct integers AAA and BBB describing one flight route. (1≤A,B≤N, A≠B)(1 \le A,B \le N,\ A \ne B)(1≤A,B≤N, A=B) This means there is a route from city AAA to city BBB.

Output

Print the maximum number of distinct cities that can be visited. If it is impossible to travel from city SSS to city TTT, print 0.