#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200009];
int ans = 0;
int dfs(int cur, int par) {
  int res = 1;
  for (int i : adj[cur]) {
    if (i != par) {
      res += dfs(i, cur);
    }
  }
  if (res & 1 ^ 1) ans++;
  return res;
}
int main() {
  int i, j, k, l, m, n, a, b;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  if (n % 2) {
    cout << -1 << "\n";
    return 0;
  }
  dfs(1, 0);
  cout << ans - 1 << "\n";
}
