N,M = list(map(int,input().split()))
dist = [[1e9 for i in range(N)] for j in range(N)]
E = []

for i in range(N):
  dist[i][i] = 0

for i in range(M):
  a,b,c = list(map(int,input().split()))
  a, b = a-1, b-1 # 0-indexed
  dist[a][b] = c
  dist[b][a] = c
  E.append([a,b,c])
  
# Warshal-Floyd
for k in range(N):
  for i in range(N):
    for j in range(N):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
  
ans = 0
for e in E:
  a,b,c = e
  flg = False
  for i in range(N):
    for j in range(N):
      if i == j : #or i == a or i == b or j == a or j == b:
        continue
      if dist[i][a] + c + dist[b][j] == dist[a][b]:
        #print(i,a,b,j)
       # print(dist[i][a], c, dist[b][j] , ":", dist[a][b])
        flg = True
        break
    if flg:
      break
  if not flg:
    ans += 1
    
print(ans)