#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long int distace[100000 + 10];
long long int visited[100000 + 10] = {0};
long long int cnt;
vector<long long int> adj[100000 + 10];
void dfs(long long int x) {
  if (visited[x]) return;
  visited[x] = 1;
  distace[x] = 1;
  for (auto u : adj[x]) {
    if (!visited[u]) {
      dfs(u);
      distace[x] += distace[u];
      if (distace[u] % 2 == 0) cnt += 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    for (long long int i = 0; i < n - 1; i += 1) {
      long long int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    dfs(1);
    long long int ans = 0;
    if (n % 2 != 0) {
      cout << -1;
      return 0;
    }
    cout << cnt;
  }
  return 0;
}
