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())
    G[a-1][b-1] = c
    G[b-1][a-1] = c

used = set()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if G[i][j] >= G[i][k]+G[k][j]:
                G[i][j] = G[i][k]+G[k][j]
                use = k
        if i != k:
            used.add((i, k))

print(M - len(used))
