N, M, *rest = $stdin.read.split.map &:to_i
E = Array.new(N+1){ Array.new(N+1) }
D = Array.new(N+1){ Array.new(N+1, Float::INFINITY) }
rest.each_slice(3) do |a, b, c|
  D[a][b] = c
  D[b][a] = c
  E[a][b] = true
  E[b][a] = true
end
U = Array.new(N+1){ Array.new(N+1) }

(1..N).each do |b|
  (1..N).each do |a|
    (1..N).each do |c|
      newd = D[a][b] + D[b][c]
      if newd < D[a][c]
        D[a][c] = newd
        U[a][b] = true
        U[b][a] = true
        U[b][c] = true
        U[c][b] = true
      end
    end
  end
end

ans = 0
(1..N).each do |a|
  (a+1..N).each do |b|
    ans += 1 if E[a][b] && !U[a][b]
  end
end
p ans

#p E: E
#p U: U
