#include "bits/stdc++.h" //#include using namespace std; //using namespace atcoder; //#define int long long #define ll long long ll INF = (1LL << 60); int mod = 1000000007; using P = pair; signed main() { int a, b; cin >> a >> b; // 短針 - 長針 int kakudo = (a * 60)%720 + (b *1)%720 - (b * 12)%720; if (kakudo < 0)kakudo += 720; cout << kakudo * 600 / 110 << endl; return 0; }