class Adjmat
  
  def initialize(n=0, inf=9876543210)
    @n = n
    @inf = inf
    @mat = Array.new(n){ Array.new(n, inf ) }.each_with_index{|s,i| s[i] = 0 }
  end
  
  def add_edge(s,t,d=1)
    @mat[s][t] = d
    @mat[t][s] = d
  end
  
  def add_directed_edge(s,t,d=1)
    @mat[s][t] = d
  end
  
  def floyd_warshall!
    @n.times do |k|
      @n.times do |i|
        @n.times do |j|
          l = @mat[i][k]
          r = @mat[k][j]
          next if l == @inf || r == @inf
          nd = l + r
          @mat[i][j] = nd if @mat[i][j] > nd
        end
      end
    end
    @mat
  end
  
  def floyd_warshall
    res = @mat
    @n.times do |k|
      @n.times do |i|
        @n.times do |j|
          l = res[i][k]
          r = res[k][j]
          next if l == @inf || r == @inf
          res[i][j] = l + r if res[i][j] > l + r
        end
      end
    end
    res
  end
  
  def negative_cycle?
    @n.times{ |i| return true if @mat[i][i] < 0}
    false
  end
  
  def out
    @n.times do |i|
      @n.times do |j|
        print @mat[i][j] == @inf ? "INF" : @mat[i][j]
        print j != @n-1 ? " " : "\n"
      end
    end
  end
end

n, m = gets.to_s.split.map{|t| t.to_i }

a = Adjmat.new(n)

edges = Array.new(m){ gets.to_s.split.map{|t| t.to_i } }

edges.each do |e|
  s = e[0] - 1
  t = e[1] - 1
  c = e[2]
  a.add_edge(s,t,c)
end

a = a.floyd_warshall

ans = 0
edges.each do |e|
  s = e[0] - 1
  t = e[1] - 1
  c = e[2]
  ok = true
  n.times do |i|
    n.times do |j|
      next if i == j
      next if i == s && j == t
      if a[i][j] == a[i][s] + c + a[t][j]
        ok = false
        break
      end
    end
  end
  ans += 1 if ok
end

puts ans