#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(b==4 || b==6 || b==9 || b==11){//小月 4 6 9 11
cout<<30;
}else if(b==2){//二月
if(a%4==0 && a%100!=0|| a%400==0){//闰年
cout<<29;
}else{
cout<<28;
}
}else{//大月
cout<<31;
}
return 0;
}
/**************************************************************
Problem: 2096
User: zy002
Language: C++
Result: Accepted
Time:15 ms
Memory:2072 kb
****************************************************************/