import java.io.*;
import java.util.*;
import java.math.*;

public class pinetree_aa {
	public static void main(String[] args) {
		new pinetree_aa().run();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(125475452);

	private void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void check(boolean u) {
		if (!u) {
			throw new Error("Assertion failed!!!");
		}
	}

	String FNAME = "pinetree";

	int MAX = (int) 1e5;

	int[] u;
	int[] r;

	private void solve() throws IOException {
		int n = nextInt();
		check(2 <= n && n <= MAX);
		Vertex[] v = new Vertex[n];
		for (int i = 0; i < v.length; i++) {
			v[i] = new Vertex(i);
		}
		u = new int[n];
		r = new int[n];
		for (int i = 0; i < u.length; i++) {
			u[i] = i;
		}
		for (int i = 0; i < n - 1; i++) {
			int x = nextInt();
			int y = nextInt();
			check(1 <= x && x <= n);
			check(1 <= y && y <= n);
			x--;
			y--;
			v[x].hs.add(y);
			v[y].hs.add(x);
			union(x, y);
		}
		TreeSet<Vertex> ts = new TreeSet<pinetree_aa.Vertex>();
		for (int i = 0; i < v.length; i++) {
			ts.add(v[i]);
		}
		int ans = 0;
		Vertex[] q = new Vertex[n];
		Vertex[] q2 = new Vertex[n];
		while (true) {
			// System.out.println("Phase " + ans);
			if (ts.size() <= 2) {
				break;
			}
			int h = 0;
			int t = 0;
			while (ts.size() > 0 && ts.first().hs.size() == 1) {
				q[t++] = ts.pollFirst();
			}
			int h2 = 0;
			int t2 = 0;
			while (h < t) {
				Vertex ver = q[h++];
				int z = remove(v, ts, ver);
				if (v[z].hs.size() == 1) {
					q2[t2++] = v[z];
				}
			}
			while (h2 < t2) {
				Vertex ver = q2[h2++];
				for (int i : ver.hs) {
					if (v[i].hs.size() == 2) {
						remove(v, ts, ver);
						q2[t2++] = v[i];
					}
				}
			}
			ans++;
		}
		out.println(ans);
	}

	private void union(int x, int y) {
		x = get(x);
		y = get(y);
		check(x != y);
		if (r[x] == r[y]) {
			r[x]++;
		}
		if (r[x] > r[y]) {
			u[y] = x;
		} else {
			u[x] = y;
		}
	}

	private int get(int x) {
		if (u[x] != x) {
			u[x] = get(u[x]);
		}
		return u[x];
	}

	private int remove(Vertex[] v, TreeSet<Vertex> ts, Vertex v0) {
		ts.remove(v0);
		int ans = -1;
		for (int i : v0.hs) {
			ans = i;
			Vertex v2 = v[i];
			ts.remove(v2);
			v2.hs.remove(v0.n);
			ts.add(v2);
		}
		return ans;
		// System.out.println(v0.n);
	}

	class Vertex implements Comparable<Vertex> {
		HashSet<Integer> hs;
		int n;

		@Override
		public String toString() {
			return "" + n;
		}

		public Vertex(int i) {
			n = i;
			hs = new HashSet<Integer>();
		}

		@Override
		public int compareTo(Vertex v) {
			if (hs.size() == v.hs.size()) {
				return n - v.n;
			}
			return hs.size() - v.hs.size();
		}
	}

}
