#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 2;
int n, ans, num[maxn], mark[maxn];
vector<int> adj[maxn];
void dfs(int v) {
  mark[v] = 1;
  int flag = 1;
  for (auto u : adj[v]) {
    if (!mark[u]) {
      flag = 0;
      dfs(u);
      num[v] += num[u];
    }
  }
  num[v]++;
}
void dfs2(int v) {
  mark[v] = 1;
  for (auto u : adj[v]) {
    if (!mark[u]) {
      dfs2(u);
      if (num[u] % 2 == 0) ans++;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (n % 2) {
    cout << -1;
    return 0;
  }
  dfs(0);
  fill(mark, mark + n, 0);
  dfs2(0);
  cout << ans << endl;
  return 0;
}
