#include <bits/stdc++.h>
using namespace std;
namespace zyt {
template <typename T>
inline bool read(T &x) {
  char c;
  bool f = false;
  x = 0;
  do c = getchar();
  while (c != EOF && c != '-' && !isdigit(c));
  if (c == EOF) return false;
  if (c == '-') f = true, c = getchar();
  do x = x * 10 + c - '0', c = getchar();
  while (isdigit(c));
  if (f) x = -x;
  return true;
}
template <typename T>
inline void write(T x) {
  static char buf[20];
  char *pos = buf;
  if (x < 0) putchar('-'), x = -x;
  do *pos++ = x % 10 + '0';
  while (x /= 10);
  while (pos > buf) putchar(*--pos);
}
const int N = 1e5 + 10;
namespace Hash {
const pair<int, int> p = pair<int, int>(1e9 + 7, 1e9 + 9),
                     seed = pair<int, int>(71, 853);
pair<int, int> pow[N << 1];
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>((a.first + b.first) % p.first,
                        (a.second + b.second) % p.second);
}
pair<int, int> operator*(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>((long long)a.first * b.first % p.first,
                        (long long)a.second * b.second % p.second);
}
void init() {
  pow[0] = make_pair(1, 1);
  for (int i = 1; i < (N << 1); i++) pow[i] = pow[i - 1] * seed;
}
}  // namespace Hash
using namespace Hash;
struct edge {
  int to, next;
} e[N << 1];
int size[N], head[N], ecnt, n;
void add(const int a, const int b) {
  e[ecnt] = (edge){b, head[a]}, head[a] = ecnt++;
}
map<pair<int, int>, pair<pair<int, int>, int> > mp;
pair<int, int> dfs(const int u, const int f) {
  if (mp.count(make_pair(u, f))) {
    size[u] = mp[make_pair(u, f)].second;
    return mp[make_pair(u, f)].first;
  }
  vector<pair<pair<int, int>, int> > tmp;
  size[u] = 1;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    pair<int, int> h = dfs(v, u);
    tmp.push_back(make_pair(h, size[v]));
    size[u] += size[v];
  }
  pair<int, int> ans = make_pair(0, 0);
  sort(tmp.begin(), tmp.end());
  for (int i = 0; i < tmp.size(); i++)
    ans = ans * pow[tmp[i].second << 1] + tmp[i].first;
  ans = ans * seed + make_pair(1, 1);
  mp[make_pair(u, f)] = make_pair(ans, size[u]);
  return ans;
}
set<pair<int, int> > s;
int deg[N];
int work() {
  read(n);
  init();
  memset(head, -1, sizeof(int[n + 1]));
  for (int i = 1; i < n; i++) {
    int a, b;
    read(a), read(b);
    add(a, b), add(b, a);
    ++deg[a], ++deg[b];
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] < 4) s.insert(dfs(i, 0));
  write(s.size());
  return 0;
}
}  // namespace zyt
int main() { return zyt::work(); }
