#include<bits/stdc++.h>
using namespace std;
int main(){
int y,j,d,a;
cin>>y>>j;
if(y%4==0&&y%100!=0||y%400==0){
a=1;
}else{
a=0;
}
if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){
cout<<"31";
}else(j==2){
if(a==1){
cout<<"29";
}else{
cout<<"28";
}
}else{
cout<<"30";
}
return 0;
}
CE!!!!!