```cpp
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(b==1 or b==3 or b==5 or b==7 or b==8 or b==10 or b==12){
cout<<31;
}
if(b==4 or b==6 or b==9 or b==11){
cout<<30;
}
if(a%400==0 or (a%4==0 and a%100!=0)){
cout<<29;
}else{
cout<<28;
}
return 0;
}
```