#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100, lg = 20;
vector<int> to[maxn];
int solve(int u, int p){
	vector<int> cnt(lg, 0);
	for(int v : to[u]){
		if(v == p) continue;
		int msk = solve(v, u);
		for(int j = 0; j < lg; j++) if((msk>>j)&1) cnt[j]++;
	}
	int b = lg - 1;
	while(b >= 0 && cnt[b] <= 1) b--;
	int c = b + 1;
	while(cnt[c] == 1) c++;
	int msk = 1<<c;
	for(int j = c+1; j < lg; j++) msk |= cnt[j]<<j;
	return msk;
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		to[u].push_back(v);
		to[v].push_back(u);
	}
	int msk = solve(1, 0);
	int b = 0;
	while(msk>>b) b++;
	cout << b - 1 << endl;
	return 0;
}

