#include <bits/stdc++.h>
using namespace std;
void dfs(int x, int p, vector<vector<int>> &v, int size[]) {
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != p) {
      dfs(v[x][i], x, v, size);
      size[x] += size[v[x][i]];
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> v(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  if (n % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  int size[n + 1];
  for (int i = 0; i <= n; i++) {
    size[i] = 1;
  }
  dfs(1, -1, v, size);
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (size[i] % 2 == 0) {
      count++;
    }
  }
  cout << max(0, count - 1) << endl;
}
