L. Right Build

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputIn a MMORPG «Path of Exile» characters grow by acquiring talents for special talent points received in a game process. Talents can depend on others. A talent can be acquired only if a character has at least one of the talents it depends on. Acquiring one talent costs one talent point. At the beginning of the game a character has a single starting talent.

Schoolboy Vasiliy decided to record a video manual how to level-up a character in a proper way, following which makes defeating other players and NPCs very easy. He numbered all talents as integers from 0 to *n*, so that the starting talent is numbered as 0. Vasiliy thinks that the only right build is acquiring two different talents *a* and *b* as quickly as possible because these talents are imbalanced and much stronger than any others. Vasiliy is lost in thought what minimal number of talent points is sufficient to acquire these talents from the start of the game.

Input

The first line contains four space-separated integers: *n*, *m*, *a* and *b* (2 ≤ *n*, *m* ≤ 2·10^{5}, 1 ≤ *a*, *b* ≤ *n*, *a* ≠ *b*) — the total number of talents, excluding the starting talent, the number of dependencies between talents, and the numbers of talents that must be acquired.

Each of the next *m* lines contains two space-separated integers: *x*_{j} and *y*_{j} (0 ≤ *x*_{j} ≤ *n*, 1 ≤ *y*_{j} ≤ *n*, *x*_{j} ≠ *y*_{j}), which means the talent *y*_{j} depends on the talent *x*_{j}. It's guaranteed that it's possible to acquire all talents given the infinite number of talent points.

Output

Output a single integer — the minimal number of talent points sufficient to acquire talents *a* and *b*.

Examples

Input

6 8 4 6

0 1

0 2

1 2

1 5

2 3

2 4

3 6

5 6

Output

4

Input

4 6 3 4

0 1

0 2

1 3

2 4

3 4

4 3

Output

3

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/18/2019 00:27:30 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|