N, M = map(int, input().split())
inf = float("inf")
dp = [[inf]*N for _ in [0]*N]
for i in range(N):dp[i][i] = 0
d = [list(map(int, input().split())) for i in range(M)]
ans = 0
 
for a,b,c in d:
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])
for a,b,c in d:
        if dp[a-1][b-1] != c:
            ans += 1
print(ans)
