#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; using ll=long long; typedef pair P; int main() { int a, b; cin>>a>>b; b=a*60+b; int k=11*b/720; cout<<720*k/11-b<