#include <bits/stdc++.h>
using namespace std;
long long i, j, n, m, f1, f2, t, k, a, b, x1, x2, w;
long long ans = -1;
vector<long long> vis;
vector<vector<long long>> adj;
long long dfs(long long v) {
  vis[v] = 1;
  long long value = 1;
  for (long long u : adj[v]) {
    if (!vis[u]) {
      value += dfs(u);
    }
  }
  if (value % 2 == 0) ans++;
  return value;
}
int main() {
  t = 1;
  while (t--) {
    cin >> n;
    adj.assign(n + 1, {});
    vis.assign(n + 1, 0);
    for (i = 1; i < n; i++) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    if (n & 1) {
      cout << -1;
      return 0;
    }
    dfs(1);
    cout << ans;
  }
}
