#include<cstdio>
#include<cctype>
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define ren for(int i=first[x];i;i=next[i])
using namespace std;
const int BufferSize=1<<16;
char buffer[BufferSize],*head,*tail;
inline char Getchar() {
if(head==tail) {
int l=fread(buffer,1,BufferSize,stdin);
tail=(head=buffer)+l;
}
return *head++;
}
inline int read() {
int x=0,f=1;char c=Getchar();
for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
return x*f;
}
const int maxn=1000010;
int n,s[maxn],first[maxn],next[maxn<<1],to[maxn<<1],e;
void AddEdge(int u,int v) {
to[++e]=v;next[e]=first[u];first[u]=e;
to[++e]=u;next[e]=first[v];first[v]=e;
}
int dfs(int x,int fa) {
s[x]=1;
ren if(to[i]!=fa) s[x]+=dfs(to[i],x);
return s[x];
}
int A[maxn],ans;
int main() {
n=read();
rep(i,2,n) AddEdge(read(),read());
dfs(1,0);
rep(i,1,n) A[s[i]]++;
rep(i,1,n) if(n%i==0) {
int cnt=0;
for(int j=i;j<=n;j+=i) cnt+=A[j];
if(cnt==n/i) ans++;
}
printf("%d\n",ans);
return 0;
}