#C7991. Good Paths in Charmland
Good Paths in Charmland
Good Paths in Charmland
You are given a network of villages connected by roads in Charmland. There are N villages and M bidirectional roads. Each road is described by three integers u, v, and w, representing a road between villages u and v with length w.
A road is considered a good path if its length is exactly L. Your task is to count the number of good paths in Charmland.
More formally, if we denote by \(\mathbf{1}_{\{w=L\}}\) the indicator function that is 1 when \(w = L\) and 0 otherwise, you need to compute:
\(\displaystyle \text{result} = \sum_{i=1}^{M} \mathbf{1}_{\{w_i = L\}}\)
Input is read from standard input and output is written to standard output.
inputFormat
The first line contains three space-separated integers: N (1 \leq N \leq 10^5), M (1 \leq M \leq 10^5), and L (the required road length).
Each of the next M lines contains three space-separated integers u, v, and w describing a road between villages u and v with length w.
outputFormat
Output a single integer — the number of good paths (roads with length exactly L).
## sample5 4 2
1 2 2
2 3 2
3 4 4
4 5 2
3