#include #include using namespace std; using namespace atcoder; using ll = long long; using P = pair; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++) #define rep2ll(i,m,n) for(ll (i)=(m);(i)<(n);(i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() const ll INF60 = 1LL<<60;//1152921504606846976 const int INF30 = 1<<30; using mint = modint998244353; using VL = vector; using VVL = vector; using VVVL = vector; using VM = vector; using VVM = vector; using VVVM = vector; using VD = vector; using VVD = vector; using VVVD = vector; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>n>>m; VL u(m), v(m); rep(i,m) cin>>u[i]>>v[i], u[i]--, v[i]--; VL din(n, 0), dout(n, 0); atcoder::dsu uf(n); rep(i,m){ uf.merge(u[i], v[i]); din[v[i]]++; dout[u[i]]++; } ll ans = 0; ll sz = 0; for(auto g:uf.groups()){ ll dsum = 0; for(auto x:g) dsum += abs(din[x] - dout[x]); ans += max(0LL, dsum/2-1); sz += max(din[g[0]],dout[g[0]])!=0; } cout<