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):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])

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

print(m-sum(used))