package main;

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	edge := make([][]int, N + 1)
	for i := 1; i <= N; i++ {
		edge[i] = make([]int, N + 1)
		for j := 1; j <= N; j++ {
			edge[i][j] = 1 << 30
		}
	}
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N)

	for i := 0; i < M; i++ {
		fmt.Scan(&a[i], &b[i], &c[i])
		edge[a[i]][b[i]] = c[i]
		edge[b[i]][a[i]] = c[i]
	}
	for k := 1; k <= N; k++ {
		for i := 1; i <= N; i++ {
			for j := 1; j <= N; j++ {
				edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j])
			}
		}
	}
	ans := M
	for k := 0; k < M; k++ {
		if edge[a[k]][b[k]] == c[k] {
			ans--
		}
	}
	fmt.Println(ans)

}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
