import java.util.*; public class Main { static ArrayList> graph = new ArrayList<>(); static int[][] dp; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < n - 1; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; graph.get(a).add(b); graph.get(b).add(a); } dp = new int[2][n]; Arrays.fill(dp[0], - 1); Arrays.fill(dp[1], - 1); System.out.println(Math.max(dfw(0, 0, 0) , dfw(0, 0, 1))); } static int dfw(int idx, int parent, int flag) { if (dp[flag][idx] >= 0) { return dp[flag][idx]; } int sum = 0; if (flag == 0) { for (int x : graph.get(idx)) { if (x == parent) { continue; } sum += Math.max(dfw(x, idx, 0), dfw(x, idx, 1)); } } else { sum++; for (int x : graph.get(idx)) { if (x == parent) { continue; } sum += Math.max(dfw(x, idx, 0), dfw(x, idx, 1) - 1); } } return dp[flag][idx] = sum; } }