import heapq

def dijkstra(graph, node, start):
  INF = float("inf")
  dist = [INF] * node
  dist[start] = 0
  que = [(0, start)]
  while que:
    cost, one_node = heapq.heappop(heap)
    for next_c, next_n in graph[one_node]:
      dist_candi = dist[one_node] + next_c
      if dist_candi < dist[next_n]:
        dist[next_node] = dist_candi
        heapq.heappush(heap, (dist[next_n], next_n))
  return dist

class SetGraph:
  def __init__(self, node_num):
    self.graph = [[] for _ in range(node_num)]

  def add_one_edge(self, start, end, cost):
    self.graph[start].append((cost, end))
    self.graph[end].append((cost, start))

  def get_graph(self):
    return self.graph 
  

n, m = map(int, input().split(" "))
graph = SetGraph(n)
add_process = SetGraph.add_one_edge
for i in range(m):
  a, b, c = map(int, input().split(" "))
  add_process(a - 1, b - 1, c)
graph = Graph.get_graph()

cost = []
for i in range(n):
  temp_cost = dijkstra(graph, n, i)
  cost.append(temp_cost)

result = 0
for i in range(n):
  for c, node in graph[i]:
    if cost[i][node] != c:
      result += 1

print(result // 2)