#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int size[100005];
int parent[100005];
int bfs(int node, int p) {
  size[node] = 1;
  parent[node] = p;
  for (int i = 0; i < adj[node].size(); i++) {
    if (adj[node][i] != p) {
      size[node] += bfs(adj[node][i], node);
    }
  }
  return size[node];
}
pair<int, int> edge[100005];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    edge[i] = {a, b};
  }
  if (n % 2) {
    cout << -1 << endl;
    return;
  }
  bfs(0, -1);
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int a = edge[i].first;
    int b = edge[i].second;
    if (size[b] > size[a]) swap(a, b);
    if (size[b] % 2 == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  ;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
