local n, m = io.read("*n", "*n")
local edge = {}
local edgeidx = {}
for i = 1, n do
  edge[i] = {}
  edgeidx[i] = {}
end
local edgeuse = {}
for i = 1, m do
  edgeuse[i] = false
  local a, b, c = io.read("*n", "*n", "*n")
  edge[a][b] = c
  edgeidx[a][b] = i
  edge[b][a] = c
  edgeidx[b][a] = i
end
local inf = 1000000007
local len = {}
local asked = {}
local function getpos()
  local cand = 0
  for i = 1, n do
    if not asked[i] then
      if cand == 0 or len[i] < len[cand] then
        cand = i
      end
    end
  end
  return cand
end
local function solve(spos)
  for i = 1, n do
    asked[i] = false
    len[i] = i == spos and 0 or inf
  end
  for i = 1, n do
    local src = getpos()
    asked[src] = true
    for dst, cost in pairs(edge[src]) do
      if len[dst] + cost == len[src] then
        edgeuse[edgeidx[dst][src]] = true
      end
      if len[src] + cost < len[dst] then
        len[dst] = len[src] + cost
      end
    end
  end
end

for i = 1, n do
  solve(i)
end

local ret = 0
for i = 1, m do
  if not edgeuse[i] then ret = ret + 1 end
end
print(ret)
