#include <bits/stdc++.h>
using namespace std;
inline int Gcd(int X, int Y) { return Y ? Gcd(Y, X % Y) : X; }
inline long long Gcd(long long X, long long Y) { return Y ? Gcd(Y, X % Y) : X; }
inline int Pow(int base, long long exp, int _mod) {
  if (!(base %= _mod)) return 0;
  int _ans = 1;
  for (; exp; exp >>= 1, base = (long long)base * base % _mod)
    exp& 1 ? _ans = (long long)_ans * base % _mod : 0;
  return _ans;
}
inline long long Pow(long long base, long long exp, long long _mod) {
  if (!(base %= _mod)) return 0;
  long long _ans = 1;
  for (; exp; exp >>= 1, base = base * base % _mod)
    exp& 1 ? _ans = _ans * base % _mod : 0;
  return _ans;
}
const int INF = 0x3f3f3f3f;
int n, q;
int f[100001];
int h[100001], nxt[200001], to[200001], tot;
inline void ins(int x, int y) {
  nxt[++tot] = h[x];
  to[tot] = y;
  h[x] = tot;
}
int DFS(int u, int fa) {
  int cnt = 0;
  for (int i = h[u]; i; i = nxt[i])
    if (to[i] != fa) cnt += DFS(to[i], u), f[u] += f[to[i]];
  f[u] += (cnt & 1);
  return (cnt & 1) ^ 1;
}
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 2; i <= (n); ++i) scanf("%d%d", &x, &y), ins(x, y), ins(y, x);
  if (n & 1) return 0 * puts("-1");
  DFS(1, 0);
  printf("%d", f[1] - 1);
  return 0;
}
