parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	d = zeros(Int,n,n)
	f = zeros(Int,n,n)
	for i in 1:m
		a,b,c = readline() |> split |> parseMap
		d[a,b] = c
		d[b,a] = c
		f[a,b] = 1
		f[b,a] = 1
	end
	for k in 1:n
		for i in 1:n
			for j in 1:n
				if d[i,j] > d[i,k] + d[k,j]
					d[i,j] = d[i,k] + d[k,j]
					f[i,j] = 0
					f[j,i] = 0
				end
			end
		end
	end
  println(f)
	println((2m-sum(f))>>1)
end

main()