///
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Apr  3 00:22:08 2018
//
package main

import (
	"fmt"
)

var N, M int
var graph [][]int

func main() {
	fmt.Scan(&N, &M)

	graph := make([][]int, N)
	dist := make([][3]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		for j := range graph[i] {
			graph[i][j] = 1 << 30
		}
	}

	for i := 0; i < M; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		a--
		b--
		dist[i][0] = a
		dist[i][1] = b
		dist[i][2] = c
		graph[a][b] = c
		graph[b][a] = c
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if graph[i][j] > graph[i][k]+graph[k][j] {
					graph[i][j] = graph[i][k] + graph[k][j]
				}
			}
		}
	}

	count := 0
	for i := range dist {
		a := dist[i][0]
		b := dist[i][1]
		c := dist[i][2]
		if graph[a][b] < c {
			count++
		}
	}
	fmt.Println(count)
}
