from copy import deepcopy
N, M = map(int, input().split())
G = [[float('inf')] * N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a][b] = c
    G[b][a] = c


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


ans = 0
for i in range(N):
    for j in range(N):
        if G[i][j] == float('inf'):
            continue
        if G[i][j] != Shortest[i][j]:
            ans += 1

print(ans // 2)
