#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> g[maxn];
int ans = 0, sz[maxn];
void dfs(int u, int fa) {
  sz[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
  }
  if (sz[u] % 2 == 0 && fa != -1) ans++, sz[u] = 0;
}
int n;
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  if (n & 1) {
    printf("%d\n", -1);
  } else {
    ans = 0;
    dfs(1, -1);
    printf("%d\n", ans);
  }
  return 0;
}
