#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int ans = 0;
vector<vector<int> > g(maxn);
vector<int> dp(maxn);
void dfs(int node, int p) {
  dp[node] = 1;
  for (auto to : g[node]) {
    if (to != p) {
      dfs(to, node);
      dp[node] += dp[to];
    }
  }
  if (node && (dp[node] & 1) == 0) {
    ans++;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int s, e;
    cin >> s >> e;
    s--;
    e--;
    g[s].emplace_back(e);
    g[e].emplace_back(s);
  }
  dfs(0, -1);
  cout << ((dp[0] & 1) == 0 ? ans : -1) << '\n';
  return 0;
}
