#include <bits/stdc++.h>
using namespace std;
map<int, int> DP[100005];
map<vector<int>, int> cha;
set<int> all;
vector<int> Next[100005];
int now = 0;
int F(int here, int fa) {
  vector<int> t;
  if (DP[here].find(fa) != DP[here].end()) return DP[here][fa];
  for (auto i : Next[here]) {
    if (i == fa) continue;
    t.push_back(F(i, here));
  }
  while (t.size() < 4) t.push_back(-1);
  sort(t.begin(), t.end());
  if (cha.find(t) == cha.end()) cha[t] = now++;
  DP[here][fa] = cha[t];
  return DP[here][fa];
}
int main() {
  int N, i, a, b;
  scanf("%d", &N);
  for (i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    Next[a].push_back(b);
    Next[b].push_back(a);
  }
  for (i = 1; i <= N; i++) {
    if (Next[i].size() < 4) all.insert(F(i, -1));
  }
  printf("%d\n", all.size());
  return 0;
}
