/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author kuric10
*/
public class Main {
/**
* @param args the command line arguments
*/
private static int hlavna, poc;
private static ArrayList<int[]>[] pole;
private static boolean[] pouzite;
public static void main
(String[] args
) { // TODO code application logic here
int a, b;
Scanner input
= new Scanner
(System.
in); int[] pomPole;
int kde;
int pomi;
while (input.hasNextLine()) {
s = input.nextLine();
pom = s.split(" ");
hlavna
= Integer.
parseInt(pom
[1]) - 1; pouzite = new boolean[poc];
for (int i = 0; i < poc; i++) {
pole[i] = new ArrayList<>();
}
for (int i = 0; i < poc - 1; i++) {
pomPole = new int[2];
s = input.nextLine();
pom = s.split(" ");
pomPole[0] = a;
pomPole[1] = b;
kde
= Integer.
parseInt(pom
[0]) - 1; /*if(pomPole[0]<kde){
pomi=kde;
kde=pomPole[0];
pomPole[0]=pomi;
}*/
pole[kde].add(pomPole);
pomPole = new int[2];
pomPole[0] = kde;
pomPole[1] = b;
pole[a].add(pomPole);
}
// vypis();
System.
out.
println(rek
(hlavna,
9999999)); }
}
private static int rek(int ja, int i) {
//System.out.println(ja);
pouzite[ja] = true;
/*
if (pole[ja].isEmpty()) {
System.out.println(ja + " " + i);
return i;
}*/
int sucet = 0;
for (int[] is : pole[ja]) {
// System.out.println(ja);
if (pouzite[is[0]]) {
continue;
}
sucet += rek(is[0], is[1]);
}
if(sucet==0)return i;
// System.out.println(ja + " " + Math.min(i, sucet));
return Math.
min(i, sucet
); }
public static void vypis() {
for (ArrayList<int[]> arrayList : pole) {
for (int[] is : arrayList) {
System.
out.
println(is
[0]+" "+is
[1]); }
}
}
}