#include <bits/stdc++.h>
using namespace std;
double PI = 3.1415926535897932384626;
vector<vector<long long> > adj(100005);
vector<long long> visited(100005);
vector<long long> dp(100005);
long long ans = 0;
void dfs(long long curr) {
  visited[curr] = 1;
  dp[curr] = 1;
  for (auto &nei : adj[curr]) {
    if (!visited[nei]) {
      dfs(nei);
      dp[curr] += dp[nei];
      if ((!(dp[nei] & 1))) {
        ans++;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i <= n; i++) {
    visited[i] = 0;
    dp[i] = 0;
  }
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
  }
  if (n & 1) {
    cout << -1;
    return 0;
  }
  dfs(1);
  cout << ans;
  return 0;
}
