#include <bits/stdc++.h>
using namespace std;
map<vector<int>, int> ma, b;
struct node {
  int y, nex;
} a[2 * 110000];
int n, f[110000], g[110000], cnt, fir[110000], len, du[110000], ans;
void ins(int x, int y) {
  a[++len].y = y;
  a[len].nex = fir[x];
  fir[x] = len;
}
void cal(int x, int fa) {
  vector<int> v;
  v.clear();
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    v.push_back(f[y]);
  }
  if (fa) v.push_back(g[fa]);
  sort(v.begin(), v.end());
  if (b.count(v) == 0) b[v] = 1, ans++;
}
void dfs1(int x, int fa) {
  vector<int> v;
  v.clear();
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    dfs1(y, x);
    v.push_back(f[y]);
  }
  sort(v.begin(), v.end());
  if (ma.count(v) == 0) ma[v] = ++cnt;
  f[x] = ma[v];
}
void dfs2(int x, int fa) {
  if (du[x] < 4) cal(x, fa);
  vector<int> v;
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    v.clear();
    for (int k1 = fir[x]; k1; k1 = a[k1].nex) {
      int y1 = a[k1].y;
      if (y1 == fa || y1 == y) continue;
      v.push_back(f[y1]);
    }
    if (fa) v.push_back(g[fa]);
    sort(v.begin(), v.end());
    if (ma.count(v) == 0) ma[v] = ++cnt;
    g[x] = ma[v];
    dfs2(y, x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ins(x, y);
    ins(y, x);
    du[x]++;
    du[y]++;
  }
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%d\n", ans);
  return 0;
}
