#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
int boss[1000],height[1000];
bool is_Integrated[1000];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int is_same(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}


int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){
		boss[i] = i;
		height[i] = 0;
		is_Integrated[i] = false;
	}

	int a,b;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&a,&b);
		a--;
		b--;
		unite(a,b);
		is_Integrated[a] = true;
		is_Integrated[b] = true;
	}

	int city_num = 0,village_num = 0;

	for(int i = 0; i < N; i++){
		if(is_Integrated[i] == true && get_boss(i) == i){
			city_num++;
		}else if(is_Integrated[i] == false){
			village_num++;
		}
	}

	printf("%d\n",abs(city_num-village_num));

	return 0;
}