import numpy as np
N, M = [int(i) for i in input().split()]

INF = int(1e18)
G = np.full((N, N), INF)
for i in range(N):
    G[i][i] = 0

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


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

ans = 0
for (a, b, c) in edge:
    flag = False
    for s in range(N):
        for t in range(N):
            flag = flag | (G[s][t] == G[s][a] + c + G[b][t])

    ans = ans + (flag == False)
print(ans)
    
        
    

