#include <stdio.h> int main() { int y,m,i; while(~scanf("%d %d",&y,&m)) { if((m==2&&y%4==0)&&(y%100!=0||y%400==0)) { printf("29\n"); } else { if((m<8&&m%2==1)||(m>=8&&m%2==0)) printf("31\n"); else if (((m%2==0&&m<8)||(m>8&&m%2==1))&&m!=2) printf("30\n"); else printf("28\n"); } }return 0; }