#include <bits/stdc++.h>
using namespace std;
int n, cnt = 0;
vector<int> a;
set<int> b;
vector<bool> used;
vector<vector<int> > g;
vector<multiset<int> > value;
map<multiset<int>, int> num;
void dfs(int x = 1) {
  used[x] = true;
  multiset<int> key;
  for (int i = 0; i < (int)g[x].size(); i++) {
    int to = g[x][i];
    if (!used[to]) {
      dfs(to);
      key.insert(a[to]);
    }
  }
  for (int i = 0; i < 4 - (int)g[x].size(); i++) key.insert(-1);
  if (x != 1) key.insert(-1);
  if (num.count(key)) {
    a[x] = num[key];
  } else {
    value.push_back(key);
    a[x] = num[key] = cnt++;
  }
}
void dfstwo(int x = 1, int prev = -1) {
  multiset<int> key = value[a[x]];
  if (x != 1) {
    key.erase(key.find(-1));
    key.insert(prev);
  }
  if ((int)g[x].size() < 4) {
    if (x == 1)
      b.insert(a[x]);
    else {
      if (num.count(key))
        b.insert(num[key]);
      else {
        num[key] = cnt++;
        b.insert(num[key]);
      }
    }
  }
  used[x] = true;
  for (int i = 0; i < (int)g[x].size(); i++) {
    int to = g[x][i];
    if (!used[to]) {
      key.erase(key.find(a[to]));
      key.insert(-1);
      if (!num.count(key)) num[key] = cnt++;
      dfstwo(to, num[key]);
      key.erase(key.find(-1));
      key.insert(a[to]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n;
  g.resize(n + 1);
  a.resize(n + 1);
  used.resize(n + 1, false);
  for (int i = 0; i < n - 1; i++) {
    int from, to;
    cin >> from >> to;
    g[from].push_back(to);
    g[to].push_back(from);
  }
  dfs();
  used.clear();
  used.resize(n + 1, false);
  dfstwo();
  cout << b.size();
  return 0;
}
