N,M=map(int,input().split());e=[[9e9]*N for _ in range(N)];g=[[0]*N for _ in range(N)]
for _ in range(M):a,b,c=map(int,input().split());e[a-1][b-1]=e[b-1][a-1]=c
for i in range(N):
 for j in range(N):
  for k in range(N):
   if e[j][k]>e[j][i]+e[i][k]:
    e[j][k]=e[j][i]+e[i][k];g[j][k]=1
print((sum(sum(l)for l in g)+2*M-N*N)//2)