#include <bits/stdc++.h>
using namespace std;
int size[100001];
bool vis[100001];
int ans = 0;
vector<int> graph[100001];
int dfs(int u) {
  vis[u] = true;
  int sz = graph[u].size(), sum = 0;
  for (int i = 0; i < sz; i++) {
    if (!vis[graph[u][i]]) {
      sum += dfs(graph[u][i]);
    }
  }
  size[u] = 1 + sum;
  if (size[u] % 2 == 0) ans++;
  return size[u];
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) vis[i] = false;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  if (n % 2)
    printf("-1\n");
  else {
    dfs(1);
    printf("%d\n", ans - 1);
  }
}
