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

import numpy as np
from scipy.sparse.csgraph import shortest_path

l = np.array([[float("inf") for i in range(n)] for j in range(n)])
ans = []
for _ in range(m):
   a,b,c = map(int,input().split())
   l[a-1][b-1] = c
   l[b-1][a-1] = c
   if a > b:
      ans.append((b,a))
   else:
      ans.append((a,b))

d, p = shortest_path(l, return_predecessors=True)


for pp in p:
   for idx, ppp in enumerate(pp):
      if idx < ppp:
         if (idx+1, ppp+1) in ans:
            ans.remove((idx+1, ppp+1))
      else:
         if (ppp+1, idx+1) in ans:
            ans.remove((ppp+1, idx+1))
print(len(ans))