#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
int arr[MAX];
int n;
vector<vector<int> > adj(MAX);
int ans = 0;
int dfs(int node, int par) {
  int sz = 1;
  for (auto &child : adj[node]) {
    if (child == par) continue;
    sz += dfs(child, node);
  }
  if (sz % 2 == 0) ans++, sz = 0;
  return sz;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n & 1) return cout << -1 << "\n", 0;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  return cout << ans - 1 << "\n", 0;
}
