#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, nxt;
} e[200010];
int tot;
int deg[100010];
int first[100010];
void build(int u, int v) {
  e[++tot] = (Edge){v, first[u]};
  first[u] = tot;
  deg[u]++;
  return;
}
int siz[100010];
int mxsiz[100010];
int f[100010];
const int Mod = 1000000007;
const int M = 10007;
int h[100010];
void dfs(int u, int lst) {
  siz[u] = 1;
  mxsiz[u] = 0;
  for (int i = first[u]; i; i = e[i].nxt)
    if (e[i].v != lst) {
      dfs(e[i].v, u);
      siz[u] += siz[e[i].v];
      mxsiz[u] = max(mxsiz[u], siz[e[i].v]);
    }
  return;
}
void solve(int u, int lst) {
  h[u] = 1;
  f[u] = (deg[u] < 4);
  vector<pair<int, int> > val;
  for (int i = first[u]; i; i = e[i].nxt)
    if (e[i].v != lst) {
      solve(e[i].v, u);
      val.push_back(make_pair(h[e[i].v], f[e[i].v]));
    }
  sort(val.begin(), val.end());
  int pre = Mod + 1;
  for (int i = 0; i < val.size(); i++) {
    int H = val[i].first, F = val[i].second;
    h[u] = ((1ll * h[u] * M % Mod * H % Mod) ^ H) % Mod;
    if (H != pre) {
      pre = H;
      f[u] += F;
    }
  }
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    build(u, v);
    build(v, u);
  }
  dfs(1, 0);
  int S = 0, T = 0;
  for (int i = 1; i <= n; i++)
    if (max(mxsiz[i], n - siz[i]) <= n / 2) {
      T = S;
      S = i;
    }
  if (T) {
    solve(S, T);
    solve(T, S);
    if (h[S] != h[T])
      printf("%d\n", f[S] + f[T]);
    else
      printf("%d\n", f[S]);
  } else {
    solve(S, 0);
    printf("%d\n", f[S]);
  }
  return 0;
}
