#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
cin>>A>>B;
if (B==1 || B==3 || B==5 || B==7 || B==8 || B==10 || B==12)
{
cout<<31;
return 0;
}
if(B==4 || B==6 || B==9 || B==11){
cout<<30;
return 0;
}
if (A%400 == 0 || (A%4==0 && A%100!=0))
{
cout<<29;
}
else
{
cout<<28;
}
return 0;
}