#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long t = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') t = t * 10 + c - 48, c = getchar();
  return t * f;
}
map<vector<int>, int> hav;
bool mp[2000001];
int n, deg[2000001], ans, x, y;
map<int, int> jy[200001];
int f[2000001], nxt[2000001], poi[2000001], cnt, tot;
inline void add(int x, int y) {
  poi[++cnt] = y;
  nxt[cnt] = f[x];
  f[x] = cnt;
}
inline int dfs(int x, int fa) {
  if (jy[x][fa]) return jy[x][fa];
  vector<int> tmp;
  for (int i = f[x]; i; i = nxt[i]) {
    if (poi[i] == fa) continue;
    tmp.push_back(dfs(poi[i], x));
  }
  sort(tmp.begin(), tmp.end());
  if (!hav[tmp]) hav[tmp] = ++tot;
  return jy[x][fa] = hav[tmp];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; ++i)
    if (deg[i] < 4) mp[dfs(i, 0)] = 1;
  for (int i = 1; i <= tot; ++i)
    if (mp[i]) ans++;
  printf("%d\n", ans);
}
