#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, t, a[100005], ans = 0;
vector<long long int> v[100005];
void dfs(int node, int parent) {
  a[node]++;
  for (auto j : v[node]) {
    if (j != parent) {
      dfs(j, node);
      a[node] += a[j];
    }
  }
  if (a[node] % 2 == 0) {
    ans++;
    a[parent] -= a[node];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  if (n & 1) {
    cout << -1;
    return 0;
  }
  for (i = 0; i < n - 1; i++) {
    cin >> j >> k;
    v[j].push_back(k);
    v[k].push_back(j);
  }
  dfs(1, 0);
  cout << ans - 1 << '\n';
  return 0;
}
