N,M=list(map(int,input().split()))
from scipy.sparse.csgraph import shortest_path,dijkstra
from scipy.sparse import csr_matrix
l=[[0]*N for i in range(N)]
ans=set()
for i in range(M):
   tmp=(list(map(int,input().split())))
   l[tmp[0]-1][tmp[1]-1]=tmp[2]
   l[tmp[1]-1][tmp[0]-1]=tmp[2]
csr=csr_matrix(l)
d,p=dijkstra(csr,return_predecessors=True)
S=p[0]

def path(N,index):
   while N != 0:
      ans.add((min(N,index),max(N,index)))
      index=N
      N=p[0][N]
   else:
      ans.add((min(N,index),max(N,index)))
for i,j in enumerate(S):
   if j == -9999:
      continue
   elif j == 0:
      ans.add((0,i))
   else:
      path(j,i)
print(M-len(ans))