#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int hd[maxn], ne[maxn * 2], to[maxn * 2], num, n, siz[maxn], ans;
void add(int x, int y) { to[++num] = y, ne[num] = hd[x], hd[x] = num; }
void dfs(int x, int fa) {
  siz[x] = 1;
  for (int i = hd[x]; i; i = ne[i]) {
    if (to[i] != fa) {
      dfs(to[i], x);
      siz[x] += siz[to[i]];
    }
  }
  if (!(siz[x] & 1)) siz[x] = 0, ans++;
}
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%d", &n);
  int uu, vv;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &uu, &vv);
    add(uu, vv), add(vv, uu);
  }
  if (n & 1) {
    puts("-1");
    return 0;
  }
  dfs(1, -1), ans--;
  printf("%d\n", ans);
  return 0;
}
