#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int ans = 0;
int csize[100005];
int dfs(int u, int fa) {
  csize[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    csize[u] += csize[v];
    if (csize[v] % 2 == 0) ans++;
  }
}
int main() {
  int n;
  while (cin >> n) {
    ans = 0;
    for (int i = 0; i <= n; i++) {
      g[i].clear();
    }
    for (int i = 0; i < n - 1; i++) {
      int x, y;
      cin >> x >> y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    if (n % 2)
      cout << "-1\n";
    else {
      dfs(1, 0);
      cout << ans << "\n";
    }
  }
  return 0;
}
