import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt() % 12; int b = sc.nextInt(); sc.close(); double tyo = b * 6.0; double tan = (60 * a + b) / 2.0; double sa = tan - tyo; if(sa < 0) sa += 360; System.out.println((int)(sa / 5.5 * 60)); } }