#include<bits/stdc++.h>
using namespace std;
int main()
{
long long year;int month;int days;
cin>>year>>month;
bool reas1,reas2;
reas1=year%4==0&&year%100!=0;
reas2=year%400==0;
if(month==2)
{
if(reas1==1||reas2==1)
days=29;
else
days=28;
}
else if(month==1||month==3||month==5||month==7||
month==8||month==10||month==12)
days=31;
else
days=30;
cout<<days;
}