Submissions will no longer be placed on the leaderboard. You may still attempt this problem for practice.

The road network of Byteland can be described as a graph with nodes, describing the cities, and edges, describing the roads. Historically, all the roads are toll roads, so each road has positive integer cost associated with it. Moreover, all the roads are bidirectional and you can reach any city from any other city of Byteland by roads.

Historically, there are two capital cities in Byteland - ByteCity and St. Byteburg. They are described as the nodes with the numbers and respectively.

Now it's time for a road reform in Byteland. The treasury has enough funds for building exactly one bidirectional road with an arbitrary positive integer cost between any pair of different cities. In order for the reform to be efficient, there is a requirement that the shortest distance between ByteCity and St. Byteburg should decrease.

Please count the number of ways the road reform can be performed, i.e. find the number of ways to build a road with a positive integer cost between an unordered pair of different cities so that the distance between the cities and decrease.

Input Format

The first line contains two space-separated integers, and , denoting the number of cities and the number of roads respectively.

Each of the following lines contain three integers, , , and , that describe a road connecting the cities with the numbers and and has the cost .

There can be multiple roads connecting the same pair of cities. You can also build a road that connects some pair of cities that are already directly connected with a road.

Constraints





It is possible to reach any city from any other city using the given road network.

Output Format

Output the number of ways to perform the road reform on a single line.

Sample Input

3 3
1 3 4
1 2 1
2 3 2

Sample Output

3

Explanation

The shortest distance between the cities and equals to . Here's the list of roads that can be added so that the shortest distance decreases.

  • A road between the cities and with a cost .
  • A road between the cities and with a cost .
  • A road between the cities and with a cost .
Loading Editor...
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score