Radewoosh has n-vertex directed weighted graph. He needs to determine distances between all pairs of vertices. He decided to use Floyd-Warshall's algorithm for that.
Correct implementation of Floyd-Warshall's algorithm.
Unfortunately Radewoosh messed up loops order and his algorithm became incorrect!
Incorrect implementation of Floyd-Warshall's algorithm.
How many distances determined by Radewoosh's algorithm will be incorrect?
The first line of input contains two integers n and m (2≤n≤2,000, 1≤m≤3,000) denoting number of vertices and number of edges in our graph, respectively.
Each of the following m lines contains three integers u_i,v_i,w_i (1≤u_i,v_i≤n, u_i=v_i, 1≤w_i≤100,000) denoting that i-th edge goes from vertex u_i to vertex v_i and has weight w_i.
No ordered pair (u_i,v_i) will be given more than once.
Output should contain one number --- number of ordered pairs of vertices which have its distance computed incorrectly by Radewoosh's algorithm.