#include <bits/stdc++.h>
using namespace std;
int ans;
int c;
void dfs(int node, vector<int> adj[], int dfsn[], int visited[]) {
  visited[node] = 1;
  c++;
  dfsn[node] = c;
  for (int i = 0; i < adj[node].size(); i++) {
    int nextnode = adj[node][i];
    if (visited[nextnode] == 0) {
      dfs(nextnode, adj, dfsn, visited);
    }
  }
  int children = c - dfsn[node];
  if (children % 2 == 1) ans++;
  return;
}
int main() {
  ans = 0;
  c = 0;
  int n;
  cin >> n;
  vector<int> adj[n];
  int t = n - 1;
  while (t--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int dfsn[n];
  int visited[n];
  for (int i = 0; i < n; i++) {
    dfsn[i] = 0;
    visited[i] = 0;
  }
  if (n % 2 == 1) {
    cout << -1;
    return 0;
  }
  dfs(0, adj, dfsn, visited);
  ans--;
  cout << ans;
  return 0;
}
