#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7, P = 1e9 + 7, Q = 1e9 + 9;
long long e[N][5], vis[N][5], ru[N];
long long n, ans;
struct has {
  long long n1, n2;
  has operator*(has a) const {
    a.n1 = a.n1 * n1 % P;
    a.n2 = a.n2 * n2 % Q;
    return a;
  }
  has operator+(has a) const {
    a.n1 = (a.n1 + n1) % P;
    a.n2 = (a.n2 + n2) % Q;
    return a;
  }
  bool operator<(has a) const { return n1 == a.n1 ? n2 < a.n2 : n1 < a.n1; }
} f[N][5], so, now;
map<has, bool> flg;
has dfs(long long x, long long fa) {
  long long v;
  for (long long i = 0; i <= 4; i++)
    if (e[x][i] == fa) v = i;
  if (vis[x][v]) return f[x][v];
  has now = (has){1, 1};
  for (long long i = 1; i <= 4 && e[x][i]; i++) {
    if (e[x][i] == fa) continue;
    so = dfs(e[x][i], x);
    now = now + so * so * so;
  }
  vis[x][v] = 1;
  return f[x][v] = now;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1, u, v; i < n; i++) {
    scanf("%lld%lld", &u, &v);
    ru[u]++;
    ru[v]++;
    e[u][ru[u]] = v;
    e[v][ru[v]] = u;
  }
  for (long long i = 1; i <= n; i++)
    if (ru[i] < 4) {
      now = dfs(i, 0);
      if (!flg[now]) ans++, flg[now] = 1;
    }
  printf("%lld\n", ans);
}
