#include <bits/stdc++.h>
using namespace std;
int cnt[100005], n, sum = 0;
vector<int> tree[100005];
int sbt(int node, int parent) {
  int i, j, k, x = 0, y;
  k = tree[node].size();
  for (i = 0; i < k; i++) {
    if (tree[node][i] == parent) continue;
    y = sbt(tree[node][i], node);
    x += y;
  }
  cnt[node] = x + 1;
  return x + 1;
}
int dlt(int node, int parent) {
  int i, j, k, x = 0, y;
  k = tree[node].size();
  for (i = 0; i < k; i++) {
    if (tree[node][i] == parent) continue;
    y = dlt(tree[node][i], node);
    x += y;
  }
  j = cnt[node] - x;
  if (j % 2 == 0) {
    sum++;
    return cnt[node];
  } else {
    return x;
  }
}
int main() {
  int a, b, c, i, j, k, x, y, z, tota, tmp;
  cin >> n;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  if (n % 2 == 1) {
    printf("-1\n");
    return 0;
  }
  a = sbt(1, -1);
  sum = 0;
  a = dlt(1, -1);
  if (sum == 0) {
    printf("-1\n");
  } else {
    printf("%d\n", sum - 1);
  }
}
