import java.util.Scanner;
import java.time.LocalDate;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) { 
           String[] str=in.nextLine().split(" ");
           int year=Integer.parseInt(str[0]);
           int month=Integer.parseInt(str[1]);
           LocalDate date=LocalDate.of(year,month,1);
           System.out.println(date.lengthOfMonth()); 
        }
    }
}