#include <bits/stdc++.h>
using namespace std;
class Task {
 public:
  vector<vector<int>> g;
  vector<int> sz;
  int cuts = 0;
  int dfs(int v, int p = -1) {
    sz[v] = 1;
    for (int u : g[v]) {
      if (u == p) continue;
      sz[v] += dfs(u, v);
      if (sz[u] % 2 == 0) {
        cuts++;
      }
    }
    return sz[v];
  }
  void solve() {
    int n;
    cin >> n;
    if (n % 2 == 1) {
      cout << "-1\n";
      return;
    }
    g.resize(n);
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      u--, v--;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    sz.resize(n);
    dfs(0);
    cout << cuts << '\n';
  }
};
void setup_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  setup_io();
  int T = 1;
  while (T--) {
    Task task;
    task.solve();
  }
  return 0;
}
