a, b = gets.split.map(&:to_r) x, y = (a * 60 + b) * 0.5, b * 6 puts ((x - y) % 360 / 5.5 * 60).floor