#include <bits/stdc++.h>
using namespace std;
list<int> adj[100009];
int visit[100009];
int ans = 0;
int DFS(int root) {
  int cnt = 1;
  auto itr = adj[root].begin();
  visit[root] = 1;
  while (itr != adj[root].end()) {
    if (visit[*itr] == 0) {
      int vcount = DFS(*itr);
      cnt += vcount;
      if (vcount % 2 == 0) {
        ++ans;
      }
    }
    ++itr;
  }
  return cnt;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int u, v;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(1);
  if (n % 2 == 1) ans = -1;
  cout << ans << endl;
  return 0;
}
