#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
inline long long add(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x + _y;
  if (_ >= _mod) _ -= _mod;
  return _;
}
inline long long sub(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x - _y;
  if (_ < 0) _ += _mod;
  return _;
}
inline long long mul(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x * _y;
  if (_ >= _mod) _ %= _mod;
  return _;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = mul(_tmp, _tmp, _mod);
  if (_x & 1) _tmp = mul(_tmp, _a, _mod);
  return _tmp;
}
long long mymul(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 0ll;
  long long _tmp = mymul(_a, _x / 2, _mod);
  _tmp = add(_tmp, _tmp, _mod);
  if (_x & 1) _tmp = add(_tmp, _a, _mod);
  return _tmp;
}
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
int __ = 1, _cs;
map<vector<int>, int> hsh;
void build() {}
int n;
vector<int> v[101010];
void init() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int ai = getint();
    int bi = getint();
    v[ai].push_back(bi);
    v[bi].push_back(ai);
  }
}
int hs[101010], mcnt;
void go(int now, int prt) {
  vector<int> vv;
  for (int son : v[now]) {
    if (son == prt) continue;
    go(son, now);
    vv.push_back(hs[son]);
  }
  sort(vv.begin(), vv.end());
  if (hsh.count(vv) == 0) hsh[vv] = mcnt++;
  hs[now] = hsh[vv];
}
set<int> S;
void go2(int now, int prt, int pl) {
  vector<int> vv;
  for (int son : v[now]) {
    if (son == prt) continue;
    vv.push_back(hs[son]);
  }
  if (prt != -1) vv.push_back(pl);
  sort(vv.begin(), vv.end());
  if (hsh.count(vv) == 0) hsh[vv] = mcnt++;
  if ((int)v[now].size() < 4) S.insert(hsh[vv]);
  for (int son : v[now]) {
    if (son == prt) continue;
    vector<int> tv;
    bool flag = false;
    for (int x : vv)
      if (x == hs[son] && !flag)
        flag = true;
      else
        tv.push_back(x);
    sort(tv.begin(), tv.end());
    if (hsh.count(tv) == 0) hsh[tv] = mcnt++;
    go2(son, now, hsh[tv]);
  }
}
void solve() {
  go(1, -1);
  go2(1, -1, -1);
  printf("%d\n", (int)S.size());
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
