#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> adj;
long long int n;
long long int cnt = 0;
vector<long long int> color, childs, parent;
void dfs(long long int v) {
  ;
  color[v] = 1;
  ;
  for (long long int u : adj[v]) {
    if (color[u] == 0) {
      parent[u] = v;
      dfs(u);
    }
    if (childs[u] % 2 == 0 && childs[u] && parent[v] != u) {
      cnt++;
    } else if (parent[v] != u)
      childs[v] += childs[u];
  }
  color[v] = 2;
  childs[v]++;
  ;
  ;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(20);
  cin >> n;
  long long int p, q;
  color.resize(n + 1, 0);
  childs.resize(n + 1, 0);
  parent.resize(n + 1, 0);
  adj.resize(n + 1);
  if (n == 1) {
    cout << -1;
    return 0;
  }
  for (long long int i = 0; i < n - 1; i++) {
    cin >> p >> q;
    adj[p].push_back(q);
    adj[q].push_back(p);
  }
  dfs(p);
  long long int flag = 1;
  if (childs[p] % 2 != 0) flag = 0;
  if (flag)
    cout << cnt;
  else
    cout << -1;
  ;
  return 0;
}
