#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, ans;
vector<int> tree[maxn];
int flag[maxn];
inline int dfs(int x) {
  int son = 1;
  flag[x] = 1;
  for (int i = 0; i < tree[x].size(); i++) {
    if (!flag[tree[x][i]]) {
      son += dfs(tree[x][i]);
    }
  }
  if (son % 2 == 0) ans++;
  return son;
}
int main() {
  scanf("%d", &n);
  int u, v;
  if (n % 2) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  dfs(1);
  printf("%d\n", ans - 1);
}
