/*
数学,钟的角度问题
*/
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
int h, m;
while(scanf("%d:%d", &h, &m) == 2 && h) {
double d = abs(h*30 + m*0.5 - m*6);
if(d - 180 > 1e-9) d = 360 - d;
printf("%.3lf\n", d);
}
return 0;
}