#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
bool viz[100005];
int nr = 0;
int dfs(int nod) {
  viz[nod] = 1;
  int d, sum = 1;
  for (int i = 0; i < v[nod].size(); ++i)
    if (!viz[v[nod][i]]) {
      d = dfs(v[nod][i]);
      sum += d;
      if (d % 2 == 0) nr++;
    }
  return sum;
}
int main() {
  int n;
  scanf("%d\n", &n);
  for (int i = 1; i < n; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    v[first].push_back(second);
    v[second].push_back(first);
  }
  if (n % 2) {
    printf("-1");
    return 0;
  }
  dfs(1);
  printf("%d", nr);
  return 0;
}
