#include <bits/stdc++.h>
using namespace std;
vector< int > g[100005]; // contains graph
vector< int > ccs[100005]; // contains connected component
//int graph[100005][100005];
vector< bool > visited;
int color[100005]; // contains color of each vertex
void bfs( int i, int j ){
queue< int > q; q.push( i );
visited[i]= true;
color[i]= 0;
ccs[j].push_back( i );
while( !q.empty() ){
int u= q.front(); q.pop();
for( int k= 0; k< g[u].size(); ++k ){
int v= g[u][k];
if( color[v]== -1 && !visited[v] ){
color[v]= 1 - color[u];
visited[v]= true;
ccs[j].push_back( v );
q.push( v );
}
}
}
}
int main(){
int n, m;
int cc= 0 ;
memset( color, -1, sizeof( color ) );
//memset( graph, 0, sizeof( graph ) );
scanf( "%d%d", &n, &m );
visited.assign( n+1, 0 );
for( int i= 0; i< m; ++i ){
int x, y;
scanf( "%d%d", &x, &y );
//graph[x][y]= 1;
//graph[y][x]= 1;
g[x].push_back( y );
g[y].push_back( x );
}
int j= 0;
for( int i= 1; i<= n; ++i ){
if( !visited[i] ){
cc++;
bfs( i, j );
j++;
}
}
//for( int i= 1; i<= n; ++i )
// cout << color[i] << " ";
int b, r;
b= r= 0;
for( int i= 0; i< cc; ++i ){
for( int j= 0; j< ccs[i].size(); ++j )
if( color[ccs[i][j]] )
r++;
else
b++;
}
cout << ( r + b - 2 ) << endl; // this is only no. of ways;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdmVjdG9yPCBpbnQgPiBnWzEwMDAwNV07CS8vIGNvbnRhaW5zIGdyYXBoCnZlY3RvcjwgaW50ID4gY2NzWzEwMDAwNV07CS8vIGNvbnRhaW5zIGNvbm5lY3RlZCBjb21wb25lbnQKLy9pbnQgZ3JhcGhbMTAwMDA1XVsxMDAwMDVdOwoKdmVjdG9yPCBib29sID4gdmlzaXRlZDsKaW50IGNvbG9yWzEwMDAwNV07CQkJLy8gY29udGFpbnMgY29sb3Igb2YgZWFjaCB2ZXJ0ZXgKCnZvaWQgYmZ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