N = int(input()) X = [[] for a in range(N)] for a in range(N-1): u,v = map(int,input().split()) X[u-1].append(v-1) X[v-1].append(u-1) Ans = 0 for a in range(N): W = [False for a in range(N)] Z = [a] W[a] = True t = 0 while len(Z) >= 1 and t < 3: T = [] for x in Z: for y in X[x]: if not W[y]: T.append(y) W[y] = True Ans += 1 t += 1 Z = T.copy() print(Ans//2)