#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> arr[100005];
int a[100005];
int dfs(int vert, int par) {
  int i;
  int an = 0;
  for (i = 0; i < arr[vert].size(); i++) {
    if (arr[vert][i] != par) an += dfs(arr[vert][i], vert);
  }
  if (arr[vert].size() == 1) {
    a[vert] = 1;
    return 1;
  }
  a[vert] = an + 1;
  return an + 1;
}
int main() {
  int i, j, k;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    arr[j].push_back(k);
    arr[k].push_back(j);
  }
  if (n & 1) {
    cout << -1 << "\n";
    return 0;
  }
  int an = 0;
  dfs(1, 0);
  for (i = 2; i <= n; i++) {
    if ((n - a[i]) % 2 == 0 && a[i] % 2 == 0) an++;
  }
  cout << an << "\n";
}
