N,M=map(int,input().split())
d=[[9999 for _ in range(N)]for _ in range(N)]

for _ in range(M):
    a,b,c=map(int,input().split())
    d[0][1]=c
    d[1][0]=c

ans=0
for k in range(N):
    for i in range(N):
        if i == k:
            continue
        for j in range(N):
            if j == k or j == i:
                continue
            if d[i][j]>d[i][k]+d[k][j]:
                d[i][j]=d[i][k]+d[k][j]
                d[j][i]=d[i][k]+d[k][j]
                ans+=1

print(ans)
