object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val towns = Array.tabulate(n){_ ⇒ new UnionFindTree}
  val isMerged = Array.tabulate(n){_ ⇒ false}
  for (_ ← 0 until m){
    val Array(a, b) = readLine.trim.split(' ').map(_.toInt - 1)
    towns(a).merge(towns(b))
    isMerged(a) = true
    isMerged(b) = true
  }
  println(
    towns.count(_.isTop).let{city ⇒ isMerged.count(!_).let{town ⇒
      math.abs(city - town * 2)
    }}
  )
  class UnionFindTree{
    private var mParent: Option[UnionFindTree] = None
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case Some(p) ⇒
          p.also{it ⇒ mParent = Some(it)}
        case None ⇒ this
      }
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)) {
        this.parent.mParent = Some(that.parent)
      }
    }
    def isSameUnion(that: UnionFindTree): Boolean = {
      this.parent == that.parent
    }
    def isTop: Boolean = mParent.isEmpty
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
