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