#include <bits/stdc++.h>
using namespace std;
const int N = 120000;
int n, hash_value, ans;
int h[N];
bool vis[N * 10];
vector<int> E[N];
map<vector<int>, int> hashmap;
void hashmap_add(vector<int> v) {
  if (hashmap.find(v) == hashmap.end()) {
    hash_value += 1;
    hashmap[v] = hash_value;
  }
}
void dfs(int x, int fa) {
  vector<int> son;
  for (int i = 0; i < E[x].size(); i++)
    if (E[x][i] != fa) {
      dfs(E[x][i], x);
      son.push_back(h[E[x][i]]);
    }
  sort(son.begin(), son.end());
  hashmap_add(son);
  h[x] = hashmap[son];
}
void dfs_ans(int x, int fa, int fa_hash) {
  if (E[x].size() < 4) {
    vector<int> near;
    for (int i = 0; i < E[x].size(); i++)
      if (E[x][i] != fa) {
        near.push_back(h[E[x][i]]);
      }
    if (fa_hash != 0) {
      near.push_back(fa_hash);
    }
    near.push_back(1);
    sort(near.begin(), near.end());
    hashmap_add(near);
    int val = hashmap[near];
    if (!vis[val]) {
      ans += 1;
      vis[val] = 1;
    }
  }
  for (int i = 0; i < E[x].size(); i++)
    if (E[x][i] != fa) {
      vector<int> son;
      for (int j = 0; j < E[x].size(); j++)
        if (j != i && E[x][j] != fa) {
          son.push_back(h[E[x][j]]);
        }
      if (fa_hash != 0) {
        son.push_back(fa_hash);
      }
      sort(son.begin(), son.end());
      hashmap_add(son);
      dfs_ans(E[x][i], x, hashmap[son]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  vector<int> single;
  hashmap_add(single);
  dfs(1, 0);
  dfs_ans(1, 0, 0);
  printf("%d\n", ans);
}
