#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 1e5 + 10;
vector<int> e[N];
int sz[N], ans;
void dfs(int now, int past) {
  sz[now] = 1;
  for (int next : e[now]) {
    if (next == past) continue;
    dfs(next, now);
    sz[now] += sz[next];
  }
  if (sz[now] % 2 == 0) ans++;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u = in() - 1, v = in() - 1;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  if (n % 2) {
    cout << -1 << endl;
    return 0;
  }
  dfs(0, -1);
  cout << ans - 1 << endl;
  return 0;
}
