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

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

not_change = set()
for i in range(N):
    for j in range(N):
        if G[i][j] == G2[i][j]:
            not_change.add((i, j))

print(M - len(not_change)//2)

