#include <stdio.h>

int main() {
    int year, month;
    while (scanf("%d %d", &year, &month) != EOF) { // 注意 while 处理多个 case
        // 64 位输出请用 printf("%lld") to 
       int day[] ={0,31,28,31,30,31,30,31,31,30,31,30,31};
       if(year % 400 ==0 || (year % 4 ==0 && year % 100 != 0))
       {
        day[2] = 29;
       }
       printf("%d\n",day[month]);

    }
    return 0;
}