from collections import defaultdict

def solve(graph, edges, n, start_idx):
  flg = [False for _ in range(n)] #未検索のノードはFlase
  flg[start_idx] = True
  
  cost = [float('inf') for _ in range(n)]
  cost[start_idx] = 0
  
  prv_edges = [[] for _ in range(n)]
  
  prv_node = start_idx  
  while not all(flg):
    for node, dis in graph[prv_node]:
      if cost[node] >= dis + cost[prv_node]:
        cost[node] = dis + cost[prv_node]
        
        tmp_edge = sorted([prv_node, node])
        if tmp_edge in edges:
          edges.remove(tmp_edge)
        for prv_edge in prv_edges[node]:
          if prv_edges[node] not in edges:
            edges.append(prv_edge)
        prv_edges[node].append(tmp_edge)
    
    min_cost = float('inf')
    tmp_idx = -1
    for i in range(n):
      if flg[i] is False and min_cost > cost[i]:
        min_cost = cost[i]
        tmp_idx = i
    prv_node = tmp_idx
    flg[prv_node] = True
    #print(start_idx, prv_node, cost, edges, prv_edges)
  return edges

n, m = map(int, input().split())
graph = defaultdict(list)
edges = []

for i in range(m):
  a,b,c = map(int, input().split())
  graph[a-1].append([b-1,c])
  graph[b-1].append([a-1,c])

for i in range(n):
  edges = solve(graph, edges, n, i)
print(len(edges))