from itertools import product

N, M = map(int, input().split())
abc = [[int(x) - 1 for x in input().split()] for _ in range(M)]

dist = [[float('inf') for _ in range(N)] for _ in range(N)]
for a, b, c in abc:
    dist[a][b] = c
    dist[b][a] = c

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

ans = 0
for a, b, c in abc:
    if dist[a][b] != c:
        ans += 1
print(ans)
