#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<long long> adj[300005];
long long vis[300005] = {0}, cnt[300005], c = 0;
void dfs(long long s) {
  vis[s] = 1;
  cnt[s] = 1;
  for (long long i = 0; i < adj[s].size(); ++i) {
    if (!vis[adj[s][i]]) {
      dfs(adj[s][i]);
      cnt[s] += cnt[adj[s][i]];
    }
  }
  if (s != 1 && cnt[s] % 2 == 0) c++;
}
int32_t main() {
  long long t = 1;
  while (t--) {
    long long n, x, y;
    cin >> n;
    if (n % 2) {
      cout << -1;
      continue;
    }
    for (long long i = 0; i < n - 1; ++i) {
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    dfs(1);
    cout << c;
  }
  return 0;
}
