package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	ans := 0
	inf := math.MaxInt32

	var g [100][100]int
	var unused [100][100]int

	for i := 0; i < n; i++ {
		for ii := 0; ii < n; ii++ {
			if i == ii {
				continue
			}
			g[i][ii] = inf
		}
	}

	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		c := getNextInt(scanner)
		g[a][b] = c
		g[b][a] = c
	}

	for m := 0; m < n; m++ {
		for l := 0; l < n; l++ {
			for r := 0; r < n; r++ {
				if l == r {
					continue
				}
				if g[l][r] == inf {
					continue
				}
				if g[l][r] > g[l][m]+g[m][r] {
					unused[l][r] = 1
				}
			}
		}
	}

	for i := 0; i < n; i++ {
		for ii := 0; ii < i; ii++ {
			if unused[i][ii] == 1 {
				ans++
			}
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}
