N, M = map(int, input().split())
INF = 10 ** 9
dist = [[INF]*N for _ in range(N)]
for i in range(N):
    dist[i][i] = 0

mem = []
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a-1, b-1
    mem.append((a,b,c))
    dist[a][b] = c
    dist[b][a] = 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])

ans = 0

for i in range(M):
    a, b, c = mem[i]
    if c != dist[a][b]:
        ans += 1

print(ans)
