#include <bits/stdc++.h>
using namespace std;
void debug(string S = "hello ! debug") {
  cout << S << endl;
  return;
}
template <class T>
void printVector(vector<T> &V) {
  cout << endl;
  for (int i = 0; i < V.size(); ++i) {
    cout << V[i] << " ";
  }
  cout << endl;
  return;
}
long long int sizeOfSt(long long int N) {
  long long int x = (long long int)(ceil(log2(N)));
  long long int max_size = 2 * (long long int)pow(2, x) - 1;
  return max_size;
}
template <class T>
T maximumFromVector(vector<T> &V) {
  T ans = V[0];
  for (int i = 1; i < V.size(); ++i) {
    ans = max(ans, V[i]);
  }
  return ans;
}
template <class T>
T minimumFromVector(vector<T> &V) {
  T ans = V[0];
  for (int i = 1; i < V.size(); ++i) {
    ans = min(ans, V[i]);
  }
  return ans;
}
template <class T>
T vectorSum(vector<T> &V) {
  T sum = 0;
  for (long long int i = 0; i < V.size(); ++i) {
    sum += V[i];
  }
  return sum;
}
pair<long long int, long long int> dfsUtil(
    long long int node, vector<vector<long long int> > &graph,
    vector<bool> &visited) {
  visited[node] = true;
  if (graph[node].size() == 0) {
    return make_pair(1, 0);
  }
  vector<pair<long long int, long long int> > v;
  for (long long int i = 0; i < graph[node].size(); ++i) {
    long long int child = graph[node][i];
    if (!visited[child]) {
      pair<long long int, long long int> childAns =
          dfsUtil(child, graph, visited);
      v.push_back(childAns);
    }
  }
  pair<long long int, long long int> nodeAns;
  nodeAns.second = 0;
  long long int cnt = 0;
  for (long long int i = 0; i < v.size(); ++i) {
    nodeAns.second += v[i].second;
    if (v[i].first % 2 == 0)
      ++nodeAns.second;
    else
      ++cnt;
  }
  cnt++;
  cnt = cnt % 2;
  nodeAns.first = cnt;
  return nodeAns;
}
int main() {
  long long int n;
  scanf("%lld", &n);
  vector<vector<long long int> > graph(n + 1);
  for (long long int i = 0; i < n - 1; ++i) {
    long long int u, v;
    scanf("%lld", &u);
    scanf("%lld", &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  vector<bool> visited(n + 1, false);
  pair<long long int, long long int> ans = dfsUtil(1, graph, visited);
  if (ans.first % 2 == 0)
    cout << ans.second;
  else
    cout << -1;
  return 0;
}
