#include using namespace std; int main(){ int a, b; cin >> a >> b; auto f=[&](int sec){ int m = sec % 3600; int h = sec; return (m * 240 <= h); }; int ans = 7200; for(int i = 0; i < 7200; i++){ int s1 = a * 3600 + b * 60 + i; s1 %= 43200; int s2 = a * 3600 + b * 60 + i + 1; s2 %= 43200; if(f(s1) && !f(s2))ans = min(ans ,i); } cout << ans << endl; }