#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100001];
int res = 0, n;
int ver[100001] = {0};
bool visited[100001] = {false};
int dfs(int st) {
  visited[st] = true;
  for (int i = 0; i < edge[st].size(); i++) {
    if (!visited[edge[st][i]]) {
      int tver = dfs(edge[st][i]);
      ver[st] += tver;
    }
  }
  ver[st]++;
  if (ver[st] % 2 == 0 && (n - ver[st]) % 2 == 0 && st != 1) {
    res++;
  }
  return ver[st];
}
int main() {
  int u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(1);
  if (res == 0 && n % 2 == 0)
    cout << 0 << endl;
  else if (res == 0)
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
