import java.util.*;
 
public class Rosencrantz {

	public static void main(String[ ] args) {
		System.out.print("How many? ");
		Scanner input = new Scanner( System.in );
		String x = input.next();
		int num = Integer.parseInt(x);
		
		int longest = 0;
		int current = 0;
		
		Random rand = new Random();
		for (int i = 0; i<num; i++) {
			int r = rand.nextInt(2);
			if (r==0) {
				current += 1;
				if (current > longest)
					longest = current;
			}
			else
				current = 0;
		}
		System.out.printf("The longest run of Heads in %d tosses was %d\n", num, longest);
	}

}
