#include <bits/stdc++.h>
using namespace std;
int n, hash_cnt;
int deg[100005];
vector<int> g[100005];
set<int> answer;
map<vector<int>, int> hs;
map<int, int> dp[100005];
int dfs(int u, int par) {
  if (dp[u].find(par) != dp[u].end()) return dp[u][par];
  vector<int> vec;
  for (int v : g[u]) {
    if (v == par) continue;
    vec.push_back(dfs(v, u));
  }
  sort(vec.begin(), vec.end());
  if (hs.find(vec) == hs.end()) hs[vec] = ++hash_cnt;
  return dp[u][par] = hs[vec];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    deg[u]++, deg[v]++;
  }
  answer.clear();
  hs.clear();
  hash_cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (deg[i] > 4) return puts("-1") & 0;
    if (deg[i] == 4) continue;
    answer.insert(dfs(i, -1));
  }
  cout << answer.size() << endl;
  return 0;
}
