import numpy as np

my_input = lambda : map(int, input().split(" "))

N, M = my_input()
dist = 100 * 1000 * np.ones([N, N])

edges = []
for i in range(M):
    a, b, c = my_input()
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
    edges.append((a, b, c))

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

print(len([e for e in edges if e[2] != dist[e[0]-1][e[1]-1]]))