from collections import Counter
import sys
sys.setrecursionlimit(100001)
def input():
    return sys.stdin.readline()[:-1]
INF = 10**9
N, M = map(int, input().split())
d = [[INF] * (N+1) for i in range(N+1)]
for i in range(N+1):
    d[i][i] = 0
es = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    d[a][b], d[b][a] = c, c
    es[i] = (a, b, c)
for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = M
for k in range(M):
    i, j, c = es[k]
    for s in range(1, N):
        if d[s][i] + c == d[s][j]:
            ans -= 1
            break
print(ans)
