A monitoring signal spreads through a network of n hubs, numbered 0 to n - 1, along
m one-way links. Link i goes from hub u to hub v and takes w time units to propagate the
signal from u to v. The signal originates at a given source hub at time 0. A hub other than the
source has "received" the signal once the fastest possible propagation delay from the source to that
hub has elapsed.
Given a deadline D, print the number of hubs (not counting the source itself) that have received the
signal at or before time D.
Input format
Line 1: two integers n m.
Next m lines: three integers u v w -- a directed link from hub u to hub v with propagation
delay w (hubs are 0-indexed).
Last line: two integers s D -- the source hub and the deadline.
Output format
A single integer: the number of hubs other than s whose fastest propagation delay from s is at
most D.
Constraints
- 1 <= n <= 1000
- 0 <= m <= 4000
- 0 <= u, v < n, u != v
- 1 <= w <= 1000
- 0 <= s < n
- 0 <= D <= 1000000