#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
vector<int> vis(N, 0);
int ans = 0;
int dfs(int u) {
  vis[u] = 1;
  int cnt = 1;
  for (int v : g[u]) {
    if (!vis[v]) cnt += dfs(v);
  }
  if (cnt % 2 == 0) ans++;
  return cnt;
}
int main() {
  int n;
  cin >> n;
  int a, b;
  for (int i = 1; i <= n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  dfs(0);
  cout << ans - 1;
  return 0;
}
