#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 100001;
const int MOD = 1000000007;
const int inf = 1234567890;
const long long INF = 1122334455667788990;
vector<vector<int> > g(N);
vector<int> sz(N), par(N);
void dfs(int u, int p = 0) {
  par[u] = p;
  sz[u] = 1;
  for (auto to : g[u]) {
    if (to == p) continue;
    dfs(to, u);
    sz[u] += sz[to];
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int tc = 1, cs = 0;
  while (tc--) {
    int n, i, u, v, k = 0;
    cin >> n;
    for (i = 1; i < n; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    dfs(1);
    bool ok = false;
    for (i = 1; i <= n; i++) {
      if (sz[i] % 2 == 0) {
        ok = true;
        if (par[i]) k++;
      }
    }
    if (sz[1] & 1) ok = false;
    if (ok)
      cout << k << '\n';
    else
      cout << -1 << '\n';
  }
}
