#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main(){ int n, m, cnt = 0, r = 0; cin >> n >> m; vector lis(2*n+1); map mp; for (ll i = 0; i < m; i++){ int a, b, t1, t2; cin >> a >> b; t1 = min(a, b); if (!lis[a] && !lis[b]){ lis[a] = t1; lis[b] = t1; } else if (lis[a] && !lis[b]){ lis[b] = lis[a]; } else if (!lis[a] && lis[b]){ lis[a] = lis[b]; } else { t1 = max(lis[a], lis[b]); t2 = min(lis[a], lis[b]); if (t1 != t2){ for (int j = 0; j < 2*n + 1; j++){ if (lis[j] == t1) lis[j] = t2; } } } } for (int j = 0; j < 2*n + 1; j++){ if (lis[j]) mp[lis[j]]++; } for (auto iter = mp.begin(); iter != mp.end(); iter++){ if (!(iter->second%2)) n -= (iter->second)/2; else { n -= (iter->second - 1)/2; r++; } if (r == 2){ cnt++; r = 0; } } cout << cnt + n << endl; }