#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T>
T sqr(T a) {
  return a * a;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T sgn(T a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
template <typename T>
T abs(T a) {
  return a > 0 ? a : -a;
}
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const ll MAXN = 1000000000 + 100;
vector<vector<ll> > g;
ll dp[100500];
ll ans = -1;
void dfs(ll v, ll k) {
  dp[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    ll to = g[v][i];
    if (to != k) {
      dfs(to, v);
      dp[v] += dp[to];
    }
  }
  if (dp[v] % 2 == 0) {
    ans++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  ll n;
  cin >> n;
  g.resize(n);
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    ll x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0);
  cout << ans;
  return 0;
}
