import java.util.Scanner object Main extends App { val sc = new Scanner(System.in) val n = sc.nextInt val a = if (n >= 12) (n - 12) else n val b = sc.nextInt val lr = 360d / (12.0d * 60 * 60) val rr = 360d / (60d * 60) val al = (a * 3600 + b * 60) * lr val br = b * 60 * rr var ans = 0 var tmp = 100000.0d for(i <- 0 to 3600) { val t = ((al + i * lr) % 360 - (br + i * rr) % 360).abs if(tmp > t) { ans = i tmp = t } } println(ans) }