N,M=map(int,input().split())
d=[[float('inf') for x in range(N)] for y in range(N)]
for i in range(N):
  d[i][i]=0
ans=[]
for i in range(M):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c
  ans.append([a-1,b-1,c])

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

res=0
for a,b,c in ans:
  if d[a][b]!=c:
    res+=1

print(res)