#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; using P = pair; queue

q; q.push( P(i, 0) ); v[i] = 1; while( q.size() ) { int u, d; tie( u, d ) = q.front(); q.pop(); if( d > 1 ) continue; for( int e : g[u] ) { if( v[e] ) continue; q.push(P(e, d + 1)); 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; }