#include <bits/stdc++.h>
using namespace std;
long long int n, m, x, mx = (long long int)2e20, mn = -(long long int)2e20;
vector<long long int> adj[(long long int)1e6 + 1];
vector<long long int> vis((long long int)1e6 + 1, 0),
    sz((long long int)1e6 + 1, 1), p((long long int)1e6 + 1);
long long int dfs(long long int u) {
  vis[u] = 1;
  sz[u] = 1;
  for (long long int v : adj[u]) {
    if (!vis[v]) {
      p[v] = u;
      sz[u] += dfs(v);
    }
  }
  return sz[u];
}
void solve() {
  long long int i, j, k;
  cin >> n;
  p[1] = 1;
  m = n - 1;
  while (m--) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  if (n % 2) {
    cout << -1;
    return;
  }
  long long int ans = 0;
  dfs(1);
  for (i = 2; i <= n; i++) {
    if (sz[i] % 2 == 0) {
      ans++;
      sz[p[i]] -= sz[i];
    }
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int T = 1;
  long long int xx = 0;
  while (T--) {
    solve();
    cout << "\n";
  }
}
