#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
const long long inf = 2147383647;
const long long mod = 1000000007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
int cnt[100005], par[100005];
std::vector<int> v[100005];
void dfs(int x, int xparent) {
  par[x] = xparent;
  cnt[x] = 1;
  for (long long i = (0); i <= (((long long)(v[x]).size()) - 1); ++i) {
    int y = v[x][i];
    if (y == par[x]) continue;
    dfs(y, x);
    cnt[x] += cnt[y];
  }
}
int f(int x) {
  int res = 0;
  for (long long i = (0); i <= (((long long)(v[x]).size()) - 1); ++i) {
    int y = v[x][i];
    if (y == par[x]) continue;
    if (!(cnt[y] & 1)) res++;
    res += f(y);
  }
  return res;
}
int main() {
  int t, n, x, y;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, -1);
  if (n & 1) {
    printf("-1");
  } else {
    printf("%d", f(1));
  }
  return 0;
}
