#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int n, ans, size[N];
bool vis[N];
vector<vector<int> > edges(N);
int dfs(int cur) {
  vis[cur] = true;
  int ret = 1;
  for (int i = (0), i_end_ = (edges[cur].size()); i < i_end_; ++i) {
    int vtx = edges[cur][i];
    if (!vis[vtx]) ret += dfs(vtx);
  }
  if (ret % 2 == 0) ans++;
  return size[cur] = ret;
}
int main() {
  scanf("%d", &n);
  if (n & 1) {
    puts("-1");
    return 0;
  }
  for (int i = (0), i_end_ = (n - 1); i < i_end_; ++i) {
    int f, t;
    scanf("%d%d", &f, &t);
    edges[f].push_back(t);
    edges[t].push_back(f);
  }
  dfs(1);
  printf("%d\n", ans - 1);
  return 0;
}
