#include <bits/stdc++.h>
inline int read() {
  int s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') s = s * 10 + (ch ^ 48), ch = getchar();
  return s;
}
unsigned long long P[6] = {0u, 76543u, 233u, 123457u, 56741857u, 1537427u};
const int N = 100100;
unsigned long long f[N];
unsigned long long g[N][5];
std::set<unsigned long long> st;
int n;
struct edges {
  int v;
  edges *last;
} edge[N << 1], *head[N];
int cnt;
inline void push(int u, int v) {
  edge[++cnt] = (edges){v, head[u]};
  head[u] = edge + cnt;
}
int a[5];
inline bool cmp(int x, int y) { return f[x] < f[y]; }
inline void dfs(int x, int fa) {
  int num = 0;
  f[x] = 1u;
  int k = 0;
  for (edges *i = head[x]; i; i = i->last) {
    k++;
    if (fa == i->v) continue;
    if (!g[x][k])
      dfs(i->v, x), g[x][k] = f[i->v];
    else
      f[i->v] = g[x][k];
  }
  for (edges *i = head[x]; i; i = i->last)
    if (fa == i->v)
      continue;
    else
      a[++num] = i->v;
  std::sort(a + 1, a + 1 + num, cmp);
  for (int i = 1; i <= num; i++) f[x] = f[x] * P[5] + f[a[i]] * P[i];
}
int red[N];
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    push(u, v);
    push(v, u);
    red[u]++, red[v]++;
  }
  for (int i = 1; i <= n; i++) {
    if (red[i] < 4) {
      dfs(i, i);
      st.insert(f[i]);
    }
  }
  printf("%d\n", st.size());
}
