n,m = gets.chomp.split(' ').map{|n| n.to_i}
disn = 100000
a = Array.new
b = Array.new
c = Array.new
dist = Array.new(100)
dist.length.times {|i| dist[i] = Array.new(100)}
for i in 0...m do
  a[i],b[i],c[i] = gets.chomp.split(' ').map{|n| n.to_i}
  a[i] =a[i]-1
  b[i] =b[i]-1
end
for i in 0...n do
  for j in 0...n do
    if i == j
      dist[i][j] = 0
    else
      dist[i][j] = disn
    end
  end
end
for i in 0...m do
  dist[a[i]][b[i]] = [dist[a[i]][b[i]],c[i]].min
  dist[b[i]][a[i]] = [dist[b[i]][a[i]],c[i]].min
end
for k in 0...n do
  for i in 0...n do
    for j in 0...n do
      dist[i][j] = [dist[i][j],dist[i][k] + dist[k][j]].min
    end
  end
end
ans = m
for i in 0...m do
  for j in 0...n do
    ans = ans - 1 if dist[j][a[i]] + c[i] == dist[j][b[i]]
  end
end
puts ans