#include using namespace std; typedef long long ll; int main() { string s1, s2; cin >> s1 >> s2; int A = 10 * (s1[0] - '0') + s1[1] - '0'; int B = 10 * (s2[0] - '0') + s2[1] - '0'; int t = 60 * 60 * A + B * 60; double t1 = 6 * B; double t2 = (30 * A) % 360 + (double)B / 2; while (abs(t1 - t2) > 0.026) { t++; double s = t % 60; double m = (t / 60) % 60; int h = (t / 3600) % 12; t1 = 6 * m + s / 10.0; t2 = (30 * h) % 360 + m / 2.0 + s / 120.0; } cout << t - (3600 * A + 60 * B) << "\n"; return 0; }