input = readlines()
n, m = input.shift.chomp.split("\s").map{|x| x.to_i}

list = {}
input.each do |l|
  a, b = l.chomp.split("\s").map{|x| x.to_i}
  list[a] = [] if list[a].nil?
  list[b] = [] if list[b].nil?
  list[a].push(b) unless list[a].include?(b)
  list[b].push(a) unless list[b].include?(a)
end

(1..n).each do |h1|
  list[h1] = [] if list[h1].nil?
  (1..n).each do |h2|
    list[h2] = [] if list[h2].nil?
    next if h1 == h2
    if (list[h1] & list[h2]).length > 0
      list[h1].push(h2) unless list[h1].include?(h2)
      list[h2].push(h1) unless list[h2].include?(h1)
    end
  end
end

groups = []
ng_group = {}
list.each do |k, nglist|
  in_group = nil
  ng_group[k] = [] if ng_group[k].nil?
  groups.each_with_index do |g, i|
    next if ng_group[k].include?(i)
    groups[i].push(k)
    in_group = i
    break unless in_group.nil?
  end
  if in_group.nil?
    groups.push([k])
    in_group = groups.length - 1
  end
  nglist.each do |h|
    ng_group[h] = [] if ng_group[h].nil?
    ng_group[h].push(in_group) unless ng_group[h].include?(in_group)
  end
end

puts groups.length
