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