#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
vector<int> vc[N + 10];
int cnt[N + 10];
int ans;
void DFS(int v, int pr = 0) {
  for (int i = 0; i < vc[v].size(); i++) {
    int u = vc[v][i];
    if (u != pr) DFS(u, v);
  }
  if (vc[v].size() == 1 && v != 1) {
    cnt[pr]++;
    return;
  }
  if (!(cnt[v] % 2)) {
    cnt[pr]++;
  } else if (v != 1)
    ans++;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 1) return cout << -1, 0;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    vc[x].push_back(y), vc[y].push_back(x);
  }
  DFS(1);
  if (cnt[0]) return cout << -1, 0;
  cout << ans;
  return 0;
}
