N, M = map(int, input().split())
G1 = [[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())
    G1[a-1][b-1] = c
    G1[b-1][a-1] = c
    G2[a-1][b-1] = c
    G2[b-1][a-1] = c

used = set()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if G1[i][j] > G1[i][k]+G1[k][j]:
                G1[i][j] = G1[i][k]+G1[k][j]
                use1 = (i+1, k+1)
                use2 = (k+1, j+1)
        used.add(use1)
        used.add(use2)
#print(used)
print(M - len(used) // 2)
