PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000069. Cạnh không thuộc đường ngắn nhất (Candidates of No Shortest Paths)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cạnh không thuộc đường ngắn nhất (Candidates of No Shortest Paths)

Candidates of No Shortest Paths

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given an undirected graph with positive edge weights, count edges that do not belong to any shortest path between any pair of vertices. Each input edge is counted separately.

Input

First n,mn,m, followed by mm undirected edges u,v,wu,v,w using 1-based vertices. Parallel edges are allowed; self-loops are not.

Output

Print the number of edges absent from every shortest path.

Subtasks

  • Subtask 1 (40 points): 2≤n≤72\le n\le 7. 0≤m≤10000\le m\le1000, 1≤w≤1061\le w\le10^6; đường vô hướng, cho phép cạnh song song.

  • Subtask 2 (60 points): 2≤n≤352\le n\le 35. 0≤m≤10000\le m\le1000, 1≤w≤1061\le w\le10^6; đường vô hướng, cho phép cạnh song song.

Examples

Input

3 3
1 2 1
2 3 1
1 3 4

Output

1

Explanation

Edge 1–3 weighs 4 while path 1–2–3 costs only 2. Therefore exactly one edge is absent from all shortest paths.