St Andrews Online Judge

Within Half an Hour

By Kay Akashi

Time: 1000 ms
Memory: 256000 kB

The code judging system is only available during contests. Check out the github repo for test cases and solutions.

Please log in.

Problem Statement

Given an underground network map consisting of nn stations named from 11 to nn, output the number of stations within 3030 minutes of walking distance from station ss if you choose the path optimally.

In mm lines, you are given aia_i, bib_i, and cic_i (1im)(1 \leq i \leq m), (1ai,bin)(1 \leq a_i, b_i \leq n), (1ci100)(1 \leq c_i \leq 100), indicating that station aia_i is bilaterally connected to station bib_i and it takes cic_i minute(s) to walk from one to another.

Note that, station ss should be counted since this can be reached in 00 minute.

Constraints

1n,m10001 \leq n, m \leq 1000, 1ai,bi,sn1 \leq a_i, b_i, s \leq n, 1ci1001 \leq c_i \leq 100.

Input

The first line of input contains three integers, nn, mm, and ss. Following are mm lines each of which contains three integers, aia_i, bib_i, and cic_i.

Output

Output the answer.

Examples

Input

4 3 1
1 2 10
1 3 5
1 4 30

Output

4

Explanation

Station 11, 22, 33, and 44 can be accessed in 00, 1010, 55, and 3030 minutes respectively. All stations can be reached within 3030 minutes hence the answer is 44.

Input

7 5 2
2 1 19
1 3 13
1 4 9
5 4 3
6 7 10

Output

3

Explanation

Station 11, 22, 33, 44, and 55 can be accessed in 1919, 00, 3232, 2828, and 3131 minutes respectively. Amongst those five stations, station 11, 22, and 44 satisfy the condition, hence the answer is 33. Note that, you cannot reach station 66 and 77 because there's no service thus you don't count them.