#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000 + 100];
long long ans;
long long dp[100000 + 100];
void dfs(long long i, long long j) {
  dp[i]++;
  for (long long y = 0; y < v[i].size(); y++) {
    if (v[i][y] != j) {
      dfs(v[i][y], i);
      dp[i] += dp[v[i][y]];
    }
  }
  if (dp[i] % 2 == 0 && i != 1) ans++;
}
int main() {
  long long n;
  cin >> n;
  for (long long y = 1; y < n; y++) {
    long long i, j;
    cin >> i >> j;
    v[i].push_back(j);
    v[j].push_back(i);
  }
  if (n % 2) {
    cout << -1;
    return 0;
  }
  dfs(1, 0);
  cout << ans;
}
