#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXM = MAXN - 1;
int n;
int ghead[MAXN], gnxt[2 * MAXM], gto[2 * MAXM], deg[MAXN];
int sz[MAXN], mxcsz[MAXN];
void dfs1(int at, int par) {
  sz[at] = 1, mxcsz[at];
  for (int x = ghead[at]; x != -1; x = gnxt[x]) {
    if (gto[x] == par) continue;
    dfs1(gto[x], at);
    sz[at] += sz[gto[x]];
    if (sz[gto[x]] > mxcsz[at]) mxcsz[at] = sz[gto[x]];
  }
}
int mem[MAXN];
map<vector<int>, int> cache;
int id(int at, int par) {
  if (mem[at] != -1) return mem[at];
  vector<int> key;
  for (int x = ghead[at]; x != -1; x = gnxt[x]) {
    if (gto[x] == par) continue;
    key.push_back(id(gto[x], at));
  }
  sort(key.begin(), key.end());
  if (cache.count(key))
    return mem[at] = cache[key];
  else
    return mem[at] = cache[key] = ((int)(cache).size());
}
int go(int at, int par) {
  int ret = deg[at] <= 3 ? 1 : 0;
  set<int> seen;
  for (int x = ghead[at]; x != -1; x = gnxt[x]) {
    if (gto[x] == par) continue;
    int cur = id(gto[x], at);
    if (seen.count(cur)) continue;
    seen.insert(cur);
    ret += go(gto[x], at);
  }
  return ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) ghead[i] = -1, deg[i] = 0;
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    gnxt[2 * i + 0] = ghead[a];
    ghead[a] = 2 * i + 0;
    gto[2 * i + 0] = b;
    ++deg[a];
    gnxt[2 * i + 1] = ghead[b];
    ghead[b] = 2 * i + 1;
    gto[2 * i + 1] = a;
    ++deg[b];
  }
  dfs1(0, -1);
  vector<int> cent;
  for (int i = (0); i < (n); ++i)
    if (2 * mxcsz[i] <= n && 2 * (n - sz[i]) <= n) cent.push_back(i);
  int ret = 0;
  memset(mem, -1, sizeof(mem));
  cache.clear();
  if (((int)(cent).size()) == 1) {
    ret = go(cent[0], -1);
  } else {
    ret = go(cent[0], cent[1]);
    if (id(cent[0], cent[1]) != id(cent[1], cent[0]))
      ret += go(cent[1], cent[0]);
  }
  printf("%d\n", ret);
}
int main() {
  run();
  return 0;
}
