#include <bits/stdc++.h>
using namespace std;
int vis[100001];
void dfs(int st, map<int, vector<int> >& mp, int* cv) {
  vis[st]++;
  cv[st] = 1;
  for (auto it = mp[st].begin(); it != mp[st].end(); it++) {
    if (!vis[*it]) {
      dfs(*it, mp, cv);
      cv[st] += cv[*it];
    }
  }
}
int main() {
  int n, v, u;
  cin >> n;
  map<int, vector<int> > mp;
  for (int i = 0; i < n - 1; i++) {
    cin >> v >> u;
    v--;
    u--;
    mp[u].push_back(v);
    mp[v].push_back(u);
  }
  if (n & 1) {
    cout << "-1\n";
    return 0;
  }
  int cv[n], cnt = 0;
  dfs(0, mp, cv);
  for (int i = 1; i < n; i++) {
    if (cv[i] % 2 == 0) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
