*
#include
#include
using namespace std;
int main()
{
int a[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int y,m;
cin>>y>>m;
if((y%400==0)||(y%4==0&&y%100!=0))
printf("%d\n",a[1][m]);
else
printf("%d\n",a[0][m]);
return 0;
}