#include <bits/stdc++.h>
#pragma GCC optimize("trapv")
#pragma GCC optimize("-Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};
using namespace std;
int n, ans;
vector<int> adj[100005];
bool vis[100005];
int dfs(int node) {
  int sm = 1;
  vis[node] = 1;
  for (int i = 0; i < adj[node].size(); i++) {
    int f = adj[node][i];
    if (vis[f]) {
      continue;
    }
    sm += dfs(f);
  }
  vis[node] = 0;
  ans += (sm % 2 == 0) - (node == 1);
  return sm;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (dfs(1) % 2) {
    cout << "-1\n";
    return 0;
  }
  cout << ans << '\n';
  return 0;
}
