#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
const int MAX_N = 1e5 + 1;
const int mod = 1000000007;
const double PI = acos(-1);
const double halfC = PI / 180;
int cut = 0;
vector<int> adj[MAX_N];
int dfs(int v, int p) {
  int cnt = 1;
  for (int c : adj[v]) {
    if (c != p) cnt += dfs(c, v);
  }
  if (cnt % 2 == 0) cut++;
  return cnt;
}
void solve() {
  int n;
  cin >> n;
  int u, v;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1);
  if (n % 2 == 1)
    cout << -1;
  else
    cout << cut - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i = 1, t = 1;
  while (i <= t) {
    solve();
    i++;
  }
  return 0;
}
