N, M = map(int, input().split())
G = [[float('inf')] * N for i in range(N)]

Edge = []
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    Edge.append([a, b, c])
    G[a][b] = c
    G[b][a] = c

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

need = 0
for a, b, c in Edge:
    for s in range(N):
        if G[s][a] + c == G[s][b]:
            need += 1
            break

print(M - need)
