# D 
N,M = map(int, input().split())
a,b,c = [],[],[]
for _ in range(M):
    ai,bi,ci = map(int, input().split())
    a.append(ai-1)
    b.append(bi-1)
    c.append(ci)

dist = [[float('inf')]*N for _ in range(N)]
for i in range(M):
    dist[a[i]][b[i]] = c[i]
    dist[b[i]][a[i]] = c[i]
#print(dist)
for mid in range(N):
    for start in range(N):
        for end in range(N):
            dist[start][end] = min(dist[start][end],
                                   dist[start][mid] + dist[mid][end])

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