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

public class pinetree_aa_nocheck {
	public static void main(String[] args) {
		new pinetree_aa_nocheck().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;

	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);
		}
		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].list.add(y);
			v[x].deg++;
			v[y].list.add(x);
			v[y].deg++;
		}
		TreeSet<Vertex> ts = new TreeSet<pinetree_aa_nocheck.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().deg == 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].deg == 1) {
					q2[t2++] = v[z];
				}
			}
			while (h2 < t2) {
				Vertex ver = q2[h2++];
				for (int i : ver.list) {
					if (v[i].deg == 2) {
						remove(v, ts, ver);
						q2[t2++] = v[i];
						break;
					}
				}
			}
			ans++;
		}
		out.println(ans);
	}

	private int remove(Vertex[] v, TreeSet<Vertex> ts, Vertex v0) {
		ts.remove(v0);
		int ans = -1;
		for (ListIterator<Integer> li = v0.list.listIterator(); li.hasNext();) {
			int i = li.next();
			if (!ts.contains(v[i])) {
				li.remove();
				continue;
			}
			ans = i;
			Vertex v2 = v[i];
			ts.remove(v2);
			v[i].deg--;
			ts.add(v2);
		}
		return ans;
		// System.out.println(v0.n);
	}

	class Vertex implements Comparable<Vertex> {
		List<Integer> list;
		int n;
		int deg;

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

		public Vertex(int i) {
			n = i;
			list = new LinkedList<Integer>();
		}

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

}
