import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.util.* fun PrintWriter.solve(sc: FastScanner) { val arr = arrayOf(Triple(0,0,0), Triple(1,5,5), Triple(2,10,10), Triple(3,16,4), Triple(4,21,9), Triple(5,27,3), Triple(6,32,8), Triple(7,38,2), Triple(8,43,7), Triple(9,49,1), Triple(10,54,6), Triple(12,0,0)) val arr2 = arr.map { it.first * 3600 + it.second * 60 + it.third * 60 / 11.0 }.toTypedArray() val a = sc.nextInt() % 12 val b = sc.nextInt() var t = a * 3600 + b * 60 for (v in arr2) { if (v - t >= 0) { println((v - t).toInt()) break } } } fun main() { val writer = PrintWriter(System.out, false) writer.solve(FastScanner(System.`in`)) writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = BufferedReader(InputStreamReader(s)) fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() fun ready() = br.ready() }