#include <bits/stdc++.h>
int n, ans, v, u;
char c[10010];
using namespace std;
int s[100010], h[100010];
vector<int> vv[100010];
void dfs(int p) {
  h[p]++;
  s[p] = 1;
  for (int i = 0; i < vv[p].size(); i++)
    if (h[vv[p][i]] == 0) {
      dfs(vv[p][i]);
      h[p] += h[vv[p][i]];
    }
  for (int i = 0; i < vv[p].size(); i++)
    if (s[vv[p][i]] == 0)
      if ((h[vv[p][i]] % 2 == 0) && ((n - h[vv[p][i]]) % 2 == 0)) ans++;
  s[p] = 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    vv[u].push_back(v);
    vv[v].push_back(u);
  }
  dfs(1);
  printf("%d\n", n % 2 == 1 ? -1 : ans);
}
