#include <bits/stdc++.h>
using namespace std;
int to[200003], nxt[200003], head[100003], tot;
int deg[100003], ok[500003];
int n, ans, cnt;
map<vector<int>, int> zyyak;
map<int, int> f[100003];
inline void add(int x, int y) {
  to[++tot] = y;
  nxt[tot] = head[x];
  head[x] = tot;
}
int dfs(int x, int fa) {
  if (f[x][fa]) {
    return f[x][fa];
  }
  vector<int> vec;
  for (int i = head[x]; i; i = nxt[i]) {
    if (to[i] != fa) {
      vec.push_back(dfs(to[i], x));
    }
  }
  sort(vec.begin(), vec.end());
  if (!zyyak[vec]) {
    zyyak[vec] = ++cnt;
  }
  f[x][fa] = zyyak[vec];
  return f[x][fa];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y), add(y, x);
    deg[x]++, deg[y]++;
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] < 4) {
      ok[dfs(i, 0)] = 1;
    }
  }
  for (int i = 1; i <= cnt; i++) {
    ans += ok[i];
  }
  cout << ans << endl;
  return 0;
}
