#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> e[100010];
int dfs(int x, int parent) {
  vector<int> v;
  for (int y : e[x]) {
    if (y == parent) continue;
    v.push_back(dfs(y, x));
  }
  int sz = 0;
  for (int a : v) {
    if (a & 1)
      sz += a;
    else
      k++;
  }
  return sz + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  if (n & 1) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    e[--u].push_back(--v);
    e[v].push_back(u);
  }
  dfs(0, 0);
  cout << k;
  return 0;
}
