#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,flag[100100][20],ans;
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];

void dfs(int x,int fa)
{
    for (edge *i=fst[x]; i; i=i->nxt)
        if (i->v!=fa)
            dfs(i->v,x);
    int w=0;
    repu(i,0,19)
        if (flag[x][i]>1)
            w=i+1;
    for (; flag[x][w]; ++w);
    ans=max(ans,w),++flag[fa][w];
    repu(i,w+1,19)
        if (flag[x][i])
            ++flag[fa][i];
}

int main()
{
    scanf("%d",&n);
    repu(i,1,n-1)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        *tp=(edge){v,fst[u]},fst[u]=tp++;
        *tp=(edge){u,fst[v]},fst[v]=tp++;
    }
    dfs(1,0);
    printf("%d\n",ans);
    return 0;
}