#include <bits/stdc++.h>
using namespace std;
int fs[500010], ff[500010], F[500010], tot, ans, l[500010], n;
inline int Read() {
  char c = getchar();
  int num = 0;
  while ('0' > c || c > '9') c = getchar();
  while ('0' <= c && c <= '9') num = num * 10 + c - '0', c = getchar();
  return (num);
}
struct Edge {
  int to, old;
} e[500010 * 2];
inline void Lnk(int x, int y) {
  e[++tot].to = y;
  e[tot].old = l[x];
  l[x] = tot;
}
int L[10000007 + 10], N, d[500010];
struct Link {
  int old;
  pair<int, int> num;
} E[500010 * 2];
inline void Ins(int x, int y) {
  E[++tot].num = make_pair(y, N);
  E[tot].old = L[x];
  L[x] = tot;
}
inline int Ask(int x, int y) {
  for (int i = L[x]; i; i = E[i].old)
    if (E[i].num.first == y) return (E[i].num.second);
  return (0);
}
inline void Dfs(int x, int y) {
  int tmp[4], ns = 0, ha1 = 70009, ha2 = 500009;
  memset(tmp, 0, sizeof(tmp));
  for (int i = l[x]; i; i = e[i].old)
    if (e[i].to != y) Dfs(e[i].to, x), tmp[ns++] = fs[e[i].to];
  sort(tmp, tmp + ns);
  for (int i = 0; i < ns; i++)
    ha1 = (ha1 * 1ll * 70009 % 10000007 + tmp[i]) % 10000007,
    ha2 = (ha2 * 1ll * 500009 % 10000007 + tmp[i]);
  fs[x] = Ask(ha1, ha2);
  if (!fs[x]) fs[x] = ++N, Ins(ha1, ha2);
}
inline void Dfs2(int x, int y) {
  int tmp[4], ns = 0, ha1 = 70009, ha2 = 500009;
  memset(tmp, 0, sizeof(tmp));
  for (int i = l[x]; i; i = e[i].old)
    if (e[i].to != y) tmp[ns++] = fs[e[i].to];
  if (y) tmp[ns++] = ff[y];
  sort(tmp, tmp + ns);
  for (int i = 0; i < ns; i++)
    ha1 = (ha1 * 1ll * 70009 % 10000007 + tmp[i]) % 10000007,
    ha2 = (ha2 * 1ll * 500009 % 10000007 + tmp[i]);
  F[x] = Ask(ha1, ha2);
  if (!F[x]) F[x] = ++N, Ins(ha1, ha2);
  d[x] = ns;
  for (int i = l[x]; i; i = e[i].old)
    if (e[i].to != y) {
      memset(tmp, 0, sizeof(tmp));
      ns = 0, ha1 = 70009, ha2 = 500009;
      for (int j = l[x]; j; j = e[j].old)
        if (e[j].to != y && e[j].to != e[i].to) tmp[ns++] = fs[e[j].to];
      if (y) tmp[ns++] = ff[y];
      sort(tmp, tmp + ns);
      for (int j = 0; j < ns; j++)
        ha1 = (ha1 * 1ll * 70009 % 10000007 + tmp[j]) % 10000007,
        ha2 = (ha2 * 1ll * 500009 % 10000007 + tmp[j]);
      ff[x] = Ask(ha1, ha2);
      if (!ff[x]) ff[x] = ++N, Ins(ha1, ha2);
      Dfs2(e[i].to, x);
    }
}
bool vis[10000007 + 10];
int main() {
  n = Read();
  for (int u, v, i = 1; i < n; i++)
    u = Read(), v = Read(), Lnk(u, v), Lnk(v, u);
  Dfs(1, 0);
  Dfs2(1, 0);
  for (int i = 1; i <= n; i++)
    if (d[i] != 4 && !vis[F[i]]) vis[F[i]] = 1, ans++;
  printf("%d\n", ans);
}
