import algorithm, tables, sets, lists, intsets, critbits, sequtils, strutils, math

const ms = 100
var d:array[1..ms,array[1..ms,int]]
var e:array[ms,tuple[a:int,b:int,c:int]]

for i in 1..ms:
    for j in 1..ms:
        if i==j:
            d[i][j] = 0
        else:
            d[i][j] = 99999999

let (n,m) = (let t = stdin.readline().split().map(parseInt);(t[0],t[1]))
for i in 0..<m:
    let (a,b,c) = (let t = stdin.readline().split().map(parseInt);(t[0],t[1],t[2]))
    e[i] = (a,b,c)
    d[a][b] = c
    d[b][a] = c

# 無向グラフの場合
for 中継 in 1..n:
    for 接続元 in 1..n-1:
        for 接続先 in 接続元..n:
            d[接続元][接続先] = min(d[接続元][接続先], d[接続元][中継] + d[中継][接続先])
            d[接続先][接続元] = d[接続元][接続先]

var ans = m

for i in 0..<m:
    let (a,b,c) = e[i]
    for j in 1..n:
        if (d[j][a]+c) == d[j][b]:
            ans -= 1
            break

echo ans