#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int n, x, y;
vector<int> G[N];
int tt = 0;
int sz[N], id[N], dd[N];
void dfs(int u, int p) {
  id[++tt] = u;
  sz[u] = 1;
  dd[u] = 1;
  for (int v : G[u])
    if (v != p && !dd[v]) {
      dfs(v, u);
      sz[u] += sz[v];
    }
}
int main() {
  scanf("%d", &n);
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, -1);
  set<int> res;
  for (int i = tt; i >= 1; --i) {
    int u = id[i];
    for (int v : G[u])
      if (sz[v] > 0 && sz[v] % 2 == 0) res.insert(v);
  }
  cout << res.size() - 1;
}
