#include using namespace std; #include using namespace atcoder; int main() { int N, M; cin >> N >> M; vector> g( N * 2 ); for( int i = 0; i < M; i++ ) { int a, b; cin >> a >> b; a--; b--; g[a].push_back( b ); g[b].push_back( a ); } vector v( N * 2 ); dsu ds( N * 2 ); for( int i = 0; i < N * 2; i++ ) { if( v[i] ) continue; queue q; q.push( i ); v[i] = 1; while( q.size() ) { int u = q.front(); q.pop(); for( int e : g[u] ) { if( v[e] ) continue; q.push( e ); v[e] = 1; ds.merge( i, e ); } } } vector> gg = ds.groups(); int sz = gg.size(), ans = N; for( int i = 0; i < sz; i++ ) ans -= gg[i].size() / 2; cout << ans << endl; }