#include <iostream>
#include <vector>
using namespace std;

const int N = 100 * 1000 + 5, LG = 20;
int ans = 0;

vector <int> adj[N];
int dp[N];
int cnt[N][LG];
bool mark[N];

int get(int x, int y) {
	return (x >> y) & 1;
}

void dfs(int v) {
	mark[v] = true;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
			dp[v] |= dp[u];
			for (int i = 0; i < LG; i++) {
				if (get(dp[u], i)) {
					cnt[v][i]++;
				}
			}
		}
	}
	int x = -1;
	for (int i = 0; i < LG; i++) {
		if (cnt[v][i] > 1) {
			x = i;
		}
	}
	x++;
	while (cnt[v][x]) {
		x++;
	}
	ans = max(ans, x);
	for (int i = 0; i < x; i++) {
		dp[v] &= (1 << LG) - 1 - (1 << i);
	}
	dp[v] |= (1 << x);
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1);
	cout << ans;
	return 0;
}
