#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100, MOD = 1e9 + 7;
int n, m, ans[N];
vector<int> tre[N];
int dfs(int cur, int par) {
  int res = 1;
  for (auto child : tre[cur])
    if (child != par) res += dfs(child, cur);
  ans[cur] = res;
  return res;
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tre[x].push_back(y);
    tre[y].push_back(x);
  }
  if (n % 2 != 0) {
    printf("-1\n");
    return;
  }
  int start = 1;
  while (tre[start].size() > 1) start++;
  int _ = dfs(start, 0);
  int ansuer = -1;
  for (int i = 1; i <= n; i++) {
    if (ans[i] % 2 == 0) ansuer++;
  }
  printf("%d\n", ansuer);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
