n, m = gets.split.map(&:to_i)

class Array
  def root i
    self[i] == i ? i : (self[i] = self.root self[i])
  end
end

uf = [*0..n]
m.times do |i|
  x, y  = gets.split.map(&:to_i)
  x = uf.root x
  y = uf.root y
  uf[x] = y if x != y
end

puts 1.upto(n).count {|i| uf.root(i) == i }