#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int d[N];
int dfs(int u, int f) {
  if (d[u] != 0) return d[u];
  int res = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == f) continue;
    res += dfs(v, u);
  }
  if (res == 0)
    return d[u] = 1;
  else
    return d[u] = res + 1;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, y;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  if (n % 2 == 1) {
    cout << "-1\n";
    return 0;
  }
  dfs(1, -1);
  int num = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] % 2 == 0) num++;
  if (num == 0)
    cout << "-1\n";
  else if (num == 1)
    cout << "0\n";
  else
    cout << num - 1 << endl;
  return 0;
}
