#include <bits/stdc++.h>
using namespace std;
map<vector<int>, int> h;
int val[202020];
vector<int> g[202020];
int viz[202020];
int vf[202020];
int x, y, N;
int NR = 2;
int add(vector<int> v) {
  for (int i = v.size(); i <= 4; ++i) {
    v.push_back(1);
  }
  sort(v.begin(), v.end());
  int val = h[v];
  if (val == 0) {
    h[v] = ++NR;
    return NR;
  } else
    return val;
}
void dfs(int x, int lvl) {
  viz[x] = lvl;
  vector<int> vc;
  for (auto n : g[x]) {
    if (viz[n] == 0) {
      dfs(n, lvl + 1);
      vc.push_back(val[n]);
    }
  }
  val[x] = add(vc);
}
void dfsx(int x, int cur) {
  vector<int> vc;
  if (cur) vc.push_back(cur);
  for (auto n : g[x]) {
    if (viz[n] > viz[x]) {
      vc.push_back(val[n]);
    }
  }
  vf[x] = add(vc);
  for (auto n : g[x]) {
    vc.clear();
    if (cur) vc.push_back(cur);
    if (viz[n] > viz[x]) {
      for (auto n1 : g[x]) {
        if (viz[n1] > viz[x] && n1 != n) {
          vc.push_back(val[n1]);
        }
      }
      dfsx(n, add(vc));
    }
  }
}
int main() {
  cin >> N;
  for (int i = 1; i < N; ++i) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 1);
  vf[1] = val[1];
  dfsx(1, 0);
  set<int> S;
  for (int i = 1; i <= N; ++i) {
    if (g[i].size() < 4) {
      S.insert(vf[i]);
    }
  }
  cout << S.size();
}
