#!/usr/bin/env python3 import sys def main(): from collections import deque N = int(input()) INF = 10 ** 16 G = [[] for _ in range(N)] def bfs(edges: "List[to]", start_node: int) -> list: q = deque() dist = [INF] * len(edges) q.append(start_node) dist[start_node] = 0 while q: now = q.popleft() for next in edges[now]: if dist[next] != INF: continue q.append(next) dist[next] = dist[now] + 1 return dist for _ in range(N - 1): a, b = map(int, input().split()) G[a - 1].append(b - 1) G[b - 1].append(a - 1) d = bfs(G, 0) i = d.index(max(d)) dd = bfs(G, i) print(N - len(set(dd))) if __name__ == '__main__': main()