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