N,M = map(int,input().split())
d = [[float('inf') for j in range(N)] for i in range(N)]
es = {}
for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    d[a][b] = d[b][a] = c
    es[(a,b)] = es[(b,a)] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for (a,b),c in es.items():
    if c != d[a][b]:
        ans += 1
print(ans // 2)
