#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long mod = 1e9 + 7;
vector<long long> tree[N];
vector<long long> sizes(N, 0);
vector<long long> visited(N, 0);
long long dfs(long long node) {
  visited[node] = 1;
  long long sum = 0;
  for (long long i = 0; i < tree[node].size(); i++) {
    long long u = tree[node][i];
    if (!visited[u]) sum += dfs(u);
  }
  sizes[node] = sum + 1;
  return sizes[node];
}
long long findans(long long node) {
  long long ans = 0;
  visited[node] = 1;
  for (long long i = 0; i < tree[node].size(); i++) {
    long long u = tree[node][i];
    if (!visited[u])
      if (sizes[u] % 2 == 0)
        ans += findans(u) + 1;
      else
        ans += findans(u);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i = 0;
  vector<long long> v;
  long long n, a, b;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  long long size = dfs(1);
  if (size % 2 == 1) {
    cout << -1;
    return 0;
  }
  for (i = 0; i <= n; i++) visited[i] = 0;
  long long ans = findans(1);
  cout << ans << endl;
}
