#include <bits/stdc++.h>
using namespace std;
vector<int> k[100005];
int ans;
int dfs(int u, int fa) {
  int cnt = 1;
  for (int i = 0; i < k[u].size(); i++) {
    int v = k[u][i];
    if (v == fa) continue;
    int t = dfs(v, u);
    if (t % 2 == 0) ans++;
    cnt += t;
  }
  return cnt;
}
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) k[i].clear();
    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      k[a].push_back(b);
      k[b].push_back(a);
    }
    if (n % 2) {
      puts("-1");
      continue;
    }
    ans = 0;
    dfs(1, 0);
    cout << ans << endl;
  }
}
