using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var map = NMap(n - 1); var tree = new List[n]; for (var i = 0; i < tree.Length; ++i) tree[i] = new List(); foreach (var edge in map) { tree[edge[0]].Add(new Pair(edge[1])); tree[edge[1]].Add(new Pair(edge[0])); } DFS1(-1, 0, tree); DFS2(-1, 0, 0, 0, tree); var ans = int.MaxValue; for (var i = 0; i < n; ++i) { var sub = 1; foreach (var next in tree[i]) sub += next.W; ans = Math.Min(ans, sub); } WriteLine(ans); } static (int b, int w) DFS1(int prev, int cur, List[] tree) { var b = 1; var w = 0; foreach (var next in tree[cur]) { if (next.To == prev) continue; var nr = DFS1(cur, next.To, tree); next.B = nr.b; next.W = nr.w; b += nr.w; w += Math.Max(nr.w, nr.b); } return (b, w); } static void DFS2(int prev, int cur, int b, int w, List[] tree) { var bsum = 1; var wsum = 0; foreach (var next in tree[cur]) { if (next.To == prev) { next.B = b; next.W = w; } bsum += next.W; wsum += Math.Max(next.B, next.W); } foreach (var next in tree[cur]) { if (next.To == prev) continue; DFS2(cur, next.To, bsum - next.W, wsum - Math.Max(next.B, next.W), tree); } } class Pair { public int To; public int B; public int W; public Pair(int to) { To = to; } public override string ToString() { return $"To: {To}, B: {B}, W: {W}"; } } }