#include <bits/stdc++.h>
using namespace std;
const long long int Mod = 998244353;
const long long int mod = 1e9 + 7;
long long int Pow(long long int a, long long int b) {
  a = a % mod;
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (res % mod);
}
long long int modInverse(long long int a, long long int m) {
  return Pow(a, m - 2);
}
const int N = 1e5 + 5;
vector<int> adj[N];
int dfs(int pos, int par, int &cnt) {
  int val = 1;
  for (auto u : adj[pos]) {
    if (u == par) continue;
    int k = dfs(u, pos, cnt);
    if (k % 2 == 0) cnt++;
    val += k;
  }
  return val;
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  if (n % 2 == 1)
    cout << -1;
  else {
    int cnt = 0;
    dfs(1, 0, cnt);
    cout << cnt;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
