#include <stdio.h>
int main ()
{
int h ,m ;
double a ,x,y, d ;
while (scanf ("%d:%d",&h ,&m) == 2 && h!=0 )
{
if (h>12) h = h -12 ;
if (m>59) m= m-59 ;
x = (30*h + .5*m) ;
y = 6*m ;
if (x>y) d = (x-y) ;
else d= (y-x) ;
a = 360.000 - d ;
if (a < d) printf ("%.3lf\n",a) ;
else printf ("%.3lf\n",d) ;
}
return 0 ;
}
int main ()
{
int h ,m ;
double a ,x,y, d ;
while (scanf ("%d:%d",&h ,&m) == 2 && h!=0 )
{
if (h>12) h = h -12 ;
if (m>59) m= m-59 ;
x = (30*h + .5*m) ;
y = 6*m ;
if (x>y) d = (x-y) ;
else d= (y-x) ;
a = 360.000 - d ;
if (a < d) printf ("%.3lf\n",a) ;
else printf ("%.3lf\n",d) ;
}
return 0 ;
}