#include<cstdio>
#include<iostream>
using namespace std;
int is_year(int year)
{
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0))
{
return true;
}
else
{
return false;
}
}
int get_day_of_month(int year, int month)
{
int day[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int days = day[month];
if (is_year(year) && month == 2)
{
days += 1;
}
return days;
}
int main()
{
int year = 0;
int month = 0;
cin >> year >> month;
int day = get_day_of_month(year, month);
printf("%d", day);
return 0;
}