#include <stdio.h>

int main() {
  	//数组下标对应月数
    int month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    int year = 0;
    int mon = 0;
    while (scanf("%d %d", &year, &mon) != EOF) {
        if (year % 400 == 0 || year % 100 != 0 && year % 4 == 0)
            month[2] = 29;//将闰年2月改成29天
        if (mon > 0 && mon <= 12)
            printf("%d\n", month[mon]);
        else
            printf("月份不对,请重新输入\n");
        month[2] = 28;//改回去,避免平年2月输出29的情况
    }
    return 0;
}