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