N,M=map(int,input().split())
Islands=[[10**9]*N for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1][b-1]=c
  Islands[b-1][a-1]=c
  Edge.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])

ans=0
for a,b,c in Edge:
  if Islands[a][b]!=c:
    ans+=1
print(ans)
    
  