#include <bits/stdc++.h>
using namespace std;
const long long MTX = 1e6;
map<long long, int> tree_id;
map<int, bool> used_vid;
struct node {
  vector<int> nb;
  int v;
  bool vs;
  vector<int> child;
  node() {
    nb.clear();
    child.clear();
    vs = false;
  }
} v[111111];
int n, vid, ans;
int tmp[4];
void build_tree(int id) {
  v[id].vs = true;
  for (int i = 0; i < v[id].nb.size(); ++i) {
    if (!v[v[id].nb[i]].vs) {
      v[id].child.push_back(v[id].nb[i]);
      build_tree(v[id].nb[i]);
    }
  }
  memset(tmp, 0, sizeof(tmp));
  for (int i = 0; i < v[id].child.size(); ++i) {
    tmp[i] = v[v[id].child[i]].v;
  }
  sort(tmp, tmp + 3);
  long long f = MTX * (MTX * tmp[0] + tmp[1]) + tmp[2];
  if (tree_id[f] == 0) {
    ++vid;
    tree_id[f] = vid;
  }
  v[id].v = tree_id[f];
}
void check_tree(int id, int pval) {
  int val = 0;
  long long f;
  memset(tmp, 0, sizeof(tmp));
  int x = 0;
  for (int i = 0; i < v[id].child.size(); ++i) {
    tmp[x++] = v[v[id].child[i]].v;
  }
  tmp[x++] = pval;
  if (x < 4) {
    sort(tmp, tmp + 3);
    f = MTX * (MTX * tmp[0] + tmp[1]) + tmp[2];
    if (tree_id[f] == 0) {
      ++vid;
      tree_id[f] = vid;
    }
    val = tree_id[f];
    if (!used_vid[val]) {
      used_vid[val] = true;
      ++ans;
    }
  }
  for (int i = 0; i < v[id].child.size(); ++i) {
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j < v[id].child.size(); ++j) {
      if (i == j) {
        tmp[j] = pval;
      } else {
        tmp[j] = v[v[id].child[j]].v;
      }
    }
    sort(tmp, tmp + 3);
    f = MTX * (MTX * tmp[0] + tmp[1]) + tmp[2];
    if (tree_id[f] == 0) {
      ++vid;
      tree_id[f] = vid;
    }
    check_tree(v[id].child[i], tree_id[f]);
  }
}
int main() {
  int a, b;
  tree_id.clear();
  used_vid.clear();
  scanf("%d", &n);
  vid = 0;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d", &a, &b);
    v[a].nb.push_back(b);
    v[b].nb.push_back(a);
  }
  int i = 1;
  while (v[i].nb.size() >= 4 && i <= n) ++i;
  if (i > n) {
    printf("0\n");
    return 0;
  }
  build_tree(i);
  ans = 0;
  check_tree(i, 0);
  printf("%d\n", ans);
}
