#include <bits/stdc++.h>
using namespace std;
int n, ans;
vector<int> G[100010];
int siz[100010];
void dfs(int x) {
  int i, y;
  siz[x] = 1;
  for (i = 0; i < G[x].size(); i++) {
    y = G[x][i];
    if (siz[y]) continue;
    dfs(y);
    siz[x] += siz[y];
  }
}
int main() {
  int i, x, y;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1);
  if (siz[1] & 1)
    printf("-1");
  else {
    for (i = 1; i <= n; i++)
      if (!(siz[i] & 1)) ans++;
    printf("%d", ans - 1);
  }
}
