import numpy as np
INF = 10**10
N, M = map(int, raw_input().split())
G = [map(int, raw_input().split()) for i in range(M)]
d = np.full((N+1, N+1), INF)
for i in range(N+1):
    d[i,i] = 0
for u, v, c in G:
    d[u, v] = d[v, u] = c
for s in range(N+1):
    for t in range(N+1):
        for u in range(N+1):
            d[s, t] = d[t, s] = min(d[s, t], d[s, u] + d[u, t])
ans = 0
for u, v, c in G:
    if c > d[u, v]:
        ans += 1
print ans