#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> graph[N];
int store[N], ct[N], n;
void dfs(int v, int prev) {
  ct[v] = 1;
  for (int i = 0; i < graph[v].size(); i++) {
    int u = graph[v][i];
    if (graph[v][i] != prev) {
      dfs(u, v);
      if ((n - ct[u]) % 2 == 0 && ct[u] % 2 == 0) {
        store[v]++;
      }
      store[v] += store[u];
      ct[v] += ct[u];
    }
  }
}
int main() {
  cin >> n;
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  if (n % 2 == 1) {
    cout << "-1";
    return 0;
  } else {
    dfs(1, 0);
    cout << store[1];
  }
  return 0;
}
