#include <bits/stdc++.h>
using namespace std;
int ans = 0;
vector<vector<int> > v;
vector<int> sz;
void dfs(int x, int p) {
  for (int to : v[x]) {
    if (to != p) {
      dfs(to, x);
      sz[x] += sz[to];
    }
  }
}
void dfs2(int x, int p) {
  for (int to : v[x]) {
    if (to != p) {
      dfs2(to, x);
    }
  }
  if (sz[x] % 2 == 0) {
    if (p != -1) {
      sz[p] -= sz[x];
      ans++;
    }
  }
}
int main() {
  int n;
  cin >> n;
  v.resize(n);
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  sz.resize(n, 1);
  dfs(0, -1);
  dfs2(0, -1);
  cout << ans;
  return 0;
}
