#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; const int inf = 1e6 + 7; int main(){ int a , b; cin >> a >> b; a %= 12; b %= 60; int second = 3600*a + 60*b; int ans = inf; int d = 3600*12/11; int x = 0; for(int i = 0; i < 12; i++){ int t = x - second; x += d; if(t < 0)continue; ans = min(ans , t); } if(ans == inf){ ans = 3600*12 - second; } cout << ans << endl; return 0; }