/*               ∧∧∩               ( ゚∀゚)/ キタ━━━━━━(゚∀゚)━━━━━━!!!!             ⊂   ノ  ゆっくり見てってね!!!!!!!!              (つ ノ     o          (ノ      \      ☆              |      o           (⌒ ⌒ヽ   /     ☆     \  (´⌒  ⌒  ⌒ヾ   /       ('⌒ ; ⌒   ::⌒  )      (´     )     ::: ) /   ☆─ (´⌒;:    ::⌒`) :;  ) */ #include #include using namespace std; using namespace atcoder; bool printb(bool f) { if (f) cout << "Yes\n"; else cout << "No\n"; return f; } #define elif else if #define rep(i, s, n) for (int i = (s); i < (int)(n); i++) #define all(a) a.begin(), a.end() // xを2進数にした際にi桁目が0か1か #define bit(x,i)((x>>i)&1) typedef long long ll; typedef long double ld; ld pi = 3.14159265358979; inline void scan(){} template inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);} // print(a, b, c) => cout << a << ' ' << b << ' ' << c << endl; inline void print(){} template inline void print(Head&head,Tail&... tail){std::cout< std::istream &operator>>(std::istream&is,std::vector&v){for(T &in:v){is>>in;}return is;} template std::ostream &operator<<(std::ostream&os,const std::vector&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;} // 2地点の距離(long double) long double coor_dist(long double xi, long double yi, long double xj, long double yj) { return sqrt(abs((xi - xj) * (xi - xj)) + abs((yi - yj) * (yi - yj))); } // 回文かどうかの判定 bool iskaibun(string s){ll k = s.size();rep(i,0,k/2){if(s[i]!=s[k-1-i]){return false;}}return true;} int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; n *= 2; vector> side(n); rep(i, 0, m) { int a, b; cin >> a >> b; a--; b--; side[a].push_back(b); side[b].push_back(a); } vector dist(n, -1); int cnt = 0, ans = 0; rep(i, 0, n) { if(dist[i] == -1) { queue q; dist[i] = cnt; q.push(i); while(!q.empty()) { int pos = q.front(); q.pop(); for(int z: side[pos]) { if(dist[z] != -1) continue; dist[z] = cnt; q.push(z); } } int w = 0; rep(i, 0, n) if(dist[i] == cnt) w++; if(w % 2 == 1) ans++; cnt++; } } cout << ans / 2 << endl; }