#include <bits/stdc++.h>
using namespace std;
vector<long long int> ed[100010];
long long int n, u, v, cnt[100010], vis[100010], ans = 0;
long long int bfs(int x) {
  for (int i = 0; i < ed[x].size(); i++) {
    int t = ed[x][i];
    if (vis[t] == 0) {
      vis[t] = 1;
      cnt[x] += bfs(t);
      vis[t] = 0;
    }
  }
  return ++cnt[x];
}
int main() {
  cin >> n;
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  vis[1] = 1;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  cnt[1] = 0;
  bfs(1);
  for (int i = 1; i <= n; i++) {
    if (cnt[i] % 2 == 0) {
      ans++;
    }
  }
  ans--;
  cout << ans;
  return 0;
}
