#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int maxn=200005; int n,a[maxn],res; vector adj[maxn]; void dfs(int u, int par){ for(auto v: adj[u]) if(v!=par) dfs(v,u),a[u]^=a[v]; res+=a[u]; } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n; for(int i=0; i> u >> v; u--,v--; adj[u].pb(v),adj[v].pb(u); } for(int i=0; i> a[i],a[i]^=1; if(count(a,a+n,1)&1){ cout << "-1\n"; return 0; } dfs(0,-1); cout << res << "\n"; }