#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<list<int>> graph(n, list<int>());
  for (int i = 0; i < graph.size() - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  stack<pair<int, int>> dfs_stack;
  enum state { _new_, _active_, _finished_ };
  vector<state> vertex_state(graph.size(), _new_);
  vector<int> subtree_bit(graph.size(), 0);
  int count = 0;
  dfs_stack.push({0, -1});
  while (!dfs_stack.empty()) {
    int vertex = dfs_stack.top().first;
    int parent = dfs_stack.top().second;
    switch (vertex_state[vertex]) {
      case _new_:
        for (int v : graph[vertex])
          if (vertex_state[v] == _new_) dfs_stack.push({v, vertex});
        vertex_state[vertex] = _active_;
        break;
      case _active_:
        subtree_bit[vertex] = 1;
        for (int v : graph[vertex])
          if (v != parent) {
            count += (subtree_bit[v] == 0);
            subtree_bit[vertex] ^= subtree_bit[v];
          }
        vertex_state[vertex] = _finished_;
      default:
        dfs_stack.pop();
        break;
    }
  }
  if (n % 2 == 0) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
