# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N, M = inpl()

G = [[0]*(N) for _ in range(N)]
E = []
for _ in range(M):
    a, b, c = inpl()
    G[a-1][b-1] = c
    G[b-1][a-1] = c
    E.append([a-1, b-1, 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])

print(sum([G[a][b] < c for a, b, c in E]))