By Kay Akashi
Given an underground network map consisting of stations named from to , output the number of stations within minutes of walking distance from station if you choose the path optimally.
In lines, you are given , , and , , , indicating that station is bilaterally connected to station and it takes minute(s) to walk from one to another.
Note that, station should be counted since this can be reached in minute.
, , .
The first line of input contains three integers, , , and . Following are lines each of which contains three integers, , , and .
Output the answer.
4 3 1
1 2 10
1 3 5
1 4 30
4
Station , , , and can be accessed in , , , and minutes respectively. All stations can be reached within minutes hence the answer is .
7 5 2
2 1 19
1 3 13
1 4 9
5 4 3
6 7 10
3
Station , , , , and can be accessed in , , , , and minutes respectively. Amongst those five stations, station , , and satisfy the condition, hence the answer is . Note that, you cannot reach station and because there's no service thus you don't count them.