Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

F. Team Rocket Rises Again

time limit per test

2.5 secondsmemory limit per test

512 megabytesinput

standard inputoutput

standard outputIt's the turn of the year, so Bash wants to send presents to his friends. There are *n* cities in the Himalayan region and they are connected by *m* bidirectional roads. Bash is living in city *s*. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu to each of them. Since there may be some cities which are not reachable from Bash's city, he only sends a Pikachu to those friends who live in a city reachable from his own city. He also wants to send it to them as soon as possible.

He finds out the minimum time for each of his Pikachus to reach its destination city. Since he is a perfectionist, he informs all his friends with the time their gift will reach them. A Pikachu travels at a speed of 1 meters per second. His friends were excited to hear this and would be unhappy if their presents got delayed. Unfortunately Team Rocket is on the loose and they came to know of Bash's plan. They want to maximize the number of friends who are unhappy with Bash.

They do this by destroying exactly one of the other *n* - 1 cities. This implies that the friend residing in that city dies, so he is unhappy as well.

Note that if a city is destroyed, all the roads directly connected to the city are also destroyed and the Pikachu may be forced to take a longer alternate route.

Please also note that only friends that are waiting for a gift count as unhappy, even if they die.

Since Bash is already a legend, can you help Team Rocket this time and find out the maximum number of Bash's friends who can be made unhappy by destroying exactly one city.

Input

The first line contains three space separated integers *n*, *m* and *s* (2 ≤ *n* ≤ 2·10^{5}, , 1 ≤ *s* ≤ *n*) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in.

Each of the next *m* lines contain three space-separated integers *u*, *v* and *w* (1 ≤ *u*, *v* ≤ *n*, *u* ≠ *v*, 1 ≤ *w* ≤ 10^{9}) denoting that there exists a road between city *u* and city *v* of length *w* meters.

It is guaranteed that no road connects a city to itself and there are no two roads that connect the same pair of cities.

Output

Print a single integer, the answer to the problem.

Examples

Input

4 4 3

1 2 1

2 3 1

2 4 1

3 1 1

Output

2

Input

7 11 2

1 2 5

1 3 5

2 4 2

2 5 2

3 6 3

3 7 3

4 6 2

3 4 2

6 7 3

4 5 7

4 7 7

Output

4

Note

In the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/22/2019 05:49:24 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|