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[n][2]; System.out.println(Math.max(dfw(0, 0, 0) , dfw(0, 0, 1))); } static int dfw(int idx, int parent, int flag) { if (dp[idx][flag] != 0) { return dp[idx][flag]; } 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[idx][flag] = sum; } }