#include<stdio.h>
int main(){
  int p[1010]={0};
  int d[1010]={0};
  int i,a,b,c=0,v=0,n,m;
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d",&a,&b);
    for(;p[a];a=p[a]);
    for(;p[b];b=p[b]);
    if(a==b)continue;
    if(d[a]> d[b])p[b]=a;
    if(d[a]<=d[b])p[a]=b;
    if(d[a]==d[b])d[b]++;
  }
  for(i=1;i<=n;i++){
    //printf("%d %d %d\n",i,p[i],d[i]);
    if(p[i])continue;
    d[i]?c++:v++;
  }
  printf("%d\n",abs(c-v));    
  return 0;
}