import java.time.LocalDate;
import java.util.Scanner;

/**
 * @author zmstart
 * @create 2022-03-18 22:18
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int y = scan.nextInt();
            int m = scan.nextInt();

            LocalDate localDate1 = LocalDate.of(y, m, 1);
            System.out.println(localDate1.lengthOfMonth());
        }
    }
}