#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)in[i]=i;
	while(m--){
		int a,b;
		cin>>a>>b;
		a--;b--;
		int d=in[b];
		in[b]=in[a];
		rep(i,n)if(d==in[i])in[i]=in[a];
	}
	vi q(n,0);
	rep(i,n)q[in[i]]++;
	int co1=0,co2=0;
	rep(i,n)if(q[i]==1)co1++;
	else if(q[i]>1)co2++;
	cout<<abs(co2-co1)<<endl;
}