#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
vector<int> g[(100009)];
void dw(int u, int p, int d, int *D) {
  D[u] = d;
  for (auto i : g[u])
    if (i ^ p) dw(i, u, d + 1, D);
}
pair<int, int> ctr(int N, int r = 0) {
  static int D[(100009)], U[(100009)], d, l;
  dw(r, -1, 0, D), dw(max_element(D, D + N) - D, -1, 0, D);
  dw(l = max_element(D, D + N) - D, -1, 0, U), d = D[l] >> 1;
  if (!(D[l] & 1))
    for (int i(0); i < N; i++)
      if (D[i] == U[i] && D[i] == d) return {i, -1};
  pair<int, int> B;
  for (int i(0); i < N; i++)
    if (D[i] == d && U[i] == d + 1)
      B.second = i;
    else if (D[i] == d + 1 && U[i] == d)
      B.first = i;
  return B;
}
unordered_map<int, long long> dp[(100009)];
long long gh(int u, int p) {
  if (dp[u].count(p)) return dp[u][p];
  long long a = 10000141, b = 1234577, S = 0;
  vector<int> Z;
  for (auto &h : g[u])
    if (h ^ p) Z.push_back(gh(h, u));
  sort(Z.begin(), Z.end());
  for (auto &h : Z) S *= a, S += h, a *= b;
  return dp[u][p] = S * a + 1;
}
int dfs(int u, int p) {
  set<long long> T;
  int S = g[u].size() < 4u;
  for (auto &h : g[u])
    if (h ^ p && !T.count(gh(h, u))) T.insert(gh(h, u)), S += dfs(h, u);
  return S;
}
int S, N, a, b;
int main(void) {
  scanf("%d", &N);
  if (N == 1) return puts("1"), 0;
  for (int i(0); i < N - 1; i++)
    scanf("%d%d", &a, &b), g[--a].push_back(--b), g[b].push_back(a);
  pair<int, int> w = ctr(N);
  S = dfs(w.first, -1);
  if (~w.second && gh(w.first, -1) == gh(w.second, -1))
    S -= dfs(w.second, w.first);
  printf("%d\n", S);
  return 0;
}
