#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = (int)1e9;
const int MODULO = (int)1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  int n;
  cin >> n;
  vector<int> graph[n];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  int k = 0;
  vector<bool> v(n, false);
  function<int(int)> dfs = [&](int current) {
    v[current] = true;
    int sum = 1;
    for (int i = 0; i < graph[current].size(); i++)
      if (!v[graph[current][i]]) {
        sum += dfs(graph[current][i]);
      }
    if (sum % 2 == 0) {
      k++;
      sum %= 2;
    }
    return sum;
  };
  if (!dfs(0)) {
    cout << k - 1 << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}
