n,m=map(int,input().split())

l=[list(map(int,input().split())) for _ in range(m)]
d=[[float("inf")]*n for _ in range(n)]

for a,b,c in l:
  d[a-1][b-1]=c
  d[b-1][a-1]=c

for k in range(n):
  for i in range(n):
    for j in range(n):
      if i==j:d[i][j]=0
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])

ans=m
for i,(a,b,c) in enumerate(l):
  f=False
  for s in range(n):
    if d[s][a-1]+c==d[s][b-1]:
      f=True
  if f:ans-=1

print(ans)