#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int res = 0;
pair<long long, long long> p[N];
vector<int> v[N];
bool vis[N];
int cnt[N] = {0};
void dfs(int r) {
  vis[r] = true;
  cnt[r] = 1;
  for (int i = 0; i < v[r].size(); i++) {
    if (vis[v[r][i]]) continue;
    dfs(v[r][i]);
    cnt[r] += cnt[v[r][i]];
    if (cnt[v[r][i]] % 2 == 0) res++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, tmp, a, b;
  cin >> n;
  tmp = n - 1;
  memset(vis, false, sizeof(vis));
  pair<int, int> p[n + 1];
  for (int i = 0; i < tmp; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    p[i] = make_pair(a, b);
  }
  dfs(1);
  if (n % 2 != 0) {
    cout << "-1";
  } else {
    cout << res;
  }
}
