local n, m = io.read("*n", "*n")
local edge = {}
for i = 1, n do edge[i] = {} end
local edgeinfo = {}
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  edge[a][b], edge[b][a] = c, c
  table.insert(edgeinfo, {a, b, c})
end

local function getlength(start_idx)
  local taskstate = {}
  for i = 1, n do taskstate[i] = false end
  local tasks = {}
  local tasknum = 0
  local done = 0

  local len = {}
  for i = 1, n do len[i] = 100000 end
  len[start_idx] = 0

  local function addtask(idx)
    if not taskstate[idx] then
      taskstate[idx] = true
      tasknum = tasknum + 1
      tasks[tasknum] = idx
    end
  end
  addtask(start_idx)

  while done < tasknum do
    done = done + 1
    local src = tasks[done]
    taskstate[src] = false
    local tmp = {}
    for dst, cost in pairs(edge[src]) do
      if len[src] + cost < len[dst] then
        len[dst] = len[src] + cost
        table.insert(tmp, dst)
      end
    end
    table.sort(tmp, function(a, b) return len[a] < len[b] end)
    for i = 1, #tmp do addtask(tmp[i]) end
  end
  return len
end
local lenall = {}
for i = 1, n do
  lenall[i] = getlength(i)
end
local ret = 0
for i = 1, m do
  local contains = false
  local edge_l, edge_r, c = edgeinfo[i][1], edgeinfo[i][2], edgeinfo[i][3]
  for src = 1, n do
    for dst = 1, n do
      if lenall[src][dst] == lenall[src][edge_l] + c + lenall[edge_r][dst] then
        contains = true
        break
      end
    end
    if contains then break end
  end
  if not contains then ret = ret + 1 end
end
print(ret)
