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

ans = 0
for k in range(N):
    flg = 0
    for i in range(N):
        for j in range(N):
            if G[i][j] > G[i][k] + G[k][j]:
                flg = 1
                G[i][j] = G[k][j]
    ans += flg

print(M - ans)
