#include using namespace std; typedef long long ll; int main() { int A, B; cin >> A >> B; A %= 12; int f1 = 2 * 6 * B; int f2 = 2 * 30 * A + B; if (f1 > f2) { cout << (720 - (f1 - f2)) * 60 / 11 << "\n"; } else { cout << (f2 - f1) * 60 / 11 << "\n"; } return 0; }