#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> edge[maxn];
int sz[maxn];
int cnt;
int dfs(int u, int fa) {
  sz[u] = 1;
  for (int i = 0; i < edge[u].size(); ++i) {
    if (edge[u][i] == fa) continue;
    sz[u] += dfs(edge[u][i], u);
  }
  if (sz[u] % 2 == 0) ++cnt;
  return sz[u];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  if (n & 1)
    cout << -1 << endl;
  else {
    dfs(1, 0);
    cout << cnt - 1 << endl;
  }
  return 0;
}
