n,m = list(map(int,input().split()))

d = []
for i in range(m):
    a,b,c = list(map(int,input().split()))
    d.append([a-1,b-1,c])

e = [[100000 for i in range(n)] for j in range(n)]

for i in range(n):
    e[i][i] = 0
for i in d:
    e[i[0]][i[1]] = i[2]
    e[i[1]][i[0]] = i[2]

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

ans = 0

for i in d:
    if e[i[0]][i[1]] != i[2]:
        ans += 1
print(ans)