n,m=map(int,input().split())
g=[[0]*n for i in range(n)]
edges=[]
for i in range(m):
  u,v,c=map(int,input().split())
  g[u-1][v-1]=g[v-1][u-1]=c
  edges.append((u-1,v-1,c))
for k in range(n):
  for i in range(n):
    for j in range(n):
      g[i][j]=min(g[i][j],g[i][k]+g[k][j])
cnt=0
flag=False
for u,v,c in edges:
  flag=False
  for i in range(n):
    for j in range(i+1,n):
      if g[i][j]==g[i][u]+c+g[v][j]:
        cnt+=1
        flag=True
        break
    if flag:
      break
print(m-cnt)