#include<bits/stdc++.h> #define int long long using namespace std; int q,w,e[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; signed main() { cin>>q>>w; if(q%100==0) if(q%400==0) e[2]=29; if(q&100!=0) if(q%4==0) e[2]=29; cout<<e[w]; return 0; }