    n, m = read_line.split.map &.to_i
    a = Array.new(m) { 0 }
    b = Array.new(m) { 0 }
    c = Array.new(m) { 0 }

    vmax = Int32::MAX / 3
    dist = Array.new(n) { Array.new(n) { vmax } }
    n.times do |i|
      dist[i][i] = 0
    end

    m.times do |i|
      a[i], b[i], c[i] = read_line.split.map &.to_i.-(1)
      dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i])
      dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i])
    end

    n.times do |k|
      n.times do |i|
        n.times do |j|
          dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])
        end
      end
    end

    ans = 0
    m.times do |i|
      ans += 1 if dist[a[i]][b[i]] < c[i]
    end

    puts ans