n,m = map(int,input().split())
D = []
ans = 0
for i in range(n):
    t = [float('inf')]*n
    t[i] = 0
    D.append(t)
L = []
for i in range(m):
    a,b,c = map(int,input().split())
    D[a-1][b-1] = c
    D[b-1][a-1] = c
    L.append([a,b,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])
for i in range(m):
    a,b,c = L[i][0],L[i][1],L[i][2]
    if D[a-1][b-1] != c:
        ans += 1
print(ans)