#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 18;
int col[N], ans, n;
vector<int> G[N];
void DFS(int v = 1, int par = 0) {
	int mx = 0, b = 0;
	for (auto u : G[v])
		if (u ^ par) 
			DFS(u, v), mx |= col[v] & col[u], col[v] |= col[u];
	while ((1 << b) <= mx || col[v] & (1 << b)) b ++;
	ans = max(ans, 31 - __builtin_clz(col[v] = col[v] & ~((1 << b) - 1) | (1 << b)));
}
int main () {
	scanf("%d", &n);
	for (int i = 1, v, u; i < n; i ++) {
		scanf("%d%d", &v, &u);
		G[v].push_back(u);
		G[u].push_back(v);
	}
	DFS();
	printf("%d", ans);
}