N,M=map(int, input().split())
edge=[list(map(int,input().split())) for i in range(M)]
inf=10**20
c=[[inf]*N for i in range(N)]
e=[[0]*N for i in range(N)]
for i,j,w in edge:
    c[i-1][j-1]=w
    c[j-1][i-1]=w
    e[i-1][j-1]=1
    e[j-1][i-1]=1
for i in range(N):
    c[i][i]=0
ans=0
def wf(c,N):
    global ans
    for k in range(N):
        for i in range(N-1):
            for j in range(i+1,N):
                if c[i][j]>c[i][k]+c[k][j]:
                    if e[i][j]==1:
                        ans+=1
                    c[i][j]=c[i][k]+c[k][j]
wf(c,N)
print(ans)