#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a par, siz; UnionFind(int N) : par(N), siz(N,1){ rep(i,N) par[i] = i; } int root(int x){ if(par[x]==x) return x; return par[x] = root(par[x]); } bool unite(int x,int y){ x = root(x); y = root(y); if(x==y) return false; if(siz[x]> n >> m; vector cnt(n,0); UnionFind uf(n); vector ok(n,true); int k = 0; rep(i,m){ int u,v; cin >> u >> v; u--; v--; k += ok[u]; k += ok[v]; ok[u] = ok[v] = false; cnt[u]++; cnt[v]--; k -= uf.unite(u,v); } k--; int ans = -2; rep(i,n) ans += abs(cnt[i]); ans /= 2; chmax(ans,0); chmax(ans,k); cout << ans << '\n'; return 0; }