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

cnt = 0
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]
                flg = True
    if flg:
        cnt += 1
    flg = False

print(M - cnt)
