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

d = [[0]*n for i in range(n)]
e = [[0]*n for i in range(n)]

for i in range(n):
    for j in range(n):
        if i!=j:
            d[i][j]=float('inf')
            e[i][j]=float('inf')

for i in range(m):
    d[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
    d[abc[i][1]-1][abc[i][0]-1]=abc[i][2]
    e[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
    e[abc[i][1]-1][abc[i][0]-1]=abc[i][2]

for i in range(n):
    for j in range(n):
        for k in range(n):
            if d[j][k]>d[j][i]+d[i][k]:
                d[j][k] = d[j][i]+d[i][k]

f = 0

for i in range(n):
    for j in range(n):
        if d[i][j]!=e[i][j]:
            f+=1

print(f//2)