import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] v1 = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int[] v2 = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while(sc.hasNext()){ int y = sc.nextInt(), m = sc.nextInt(); if(y%400 == 0 ||(y%4 == 0 && y %100 != 0)){ System.out.println(v2[m]); continue; } System.out.println(v1[m]); } } }