#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, cnt, ans;
int head[maxn], sz[maxn];
struct Edge {
  int v, nx;
} e[maxn << 1];
inline void add(int u, int v) {
  e[cnt].v = v;
  e[cnt].nx = head[u];
  head[u] = cnt++;
}
void dfs2(int u, int fa) {
  sz[u] = 1;
  for (int i = head[u]; i != -1; i = e[i].nx) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs2(v, u);
    sz[u] += sz[v];
  }
  if (sz[u] % 2 == 0) ans++;
}
int main() {
  while (~scanf("%d", &n)) {
    cnt = ans = 0;
    memset(head, -1, sizeof(head));
    int u, v;
    for (int i = 1; i < n; i++) {
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    if (n & 1) {
      puts("-1");
      continue;
    }
    memset(sz, 0, sizeof(sz));
    dfs2(1, 0);
    printf("%d\n", ans - 1);
  }
  return 0;
}
