n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

n += 1

M = [[float("inf")] * n for i in range(n)]

for i in range(n):
    M[i][i] = 0
for i in range(m):
    M[A[i][0]][A[i][1]] = A[i][2]
    M[A[i][1]][A[i][0]] = A[i][2]

for k in range(n):
    for i in range(n):
        for j in range(n):
            M[i][j] = min(M[i][j], M[i][k] + M[k][j])

ans = 0
for i in range(m):
    if M[A[i][0]][A[i][1]] != A[i][2]:
        ans += 1
print(ans)