#include <iostream>
using namespace std;
int main(){
int h,m;char dot;
double total;
while(1){
cin>>h>>dot>>m;
if((h == 0)&&(m==0)) break;
double hd = h*30+m*0.5;
double md = 6*m;
total = abs(hd-md);
if(total>180) total = 360-total;
cout.precision(3);
cout<<fixed<<total<<endl;
}
}