#include<bits/stdc++.h> using namespace std; const int N=1e5+5; int y,m; int main() { cin>>y>>m; if(m==3||m==9||m==6||m==11) cout<<30; else if(m==2){ if(y%400==0||y%4==0&&y%100!=0){ cout<<29; } else cout<<28; } else cout<<31; return 0; }