#include<stdio.h>
#include<math.h>
#define pi 3.1415926535897932384626
int main(){
    double i=0,till=0,n,ans,a=3,b=4,h=10,m=40;
    //scanf("%lf %lf %lf %lf", &a, &b,&c,&d);
    h=(double)(((int)h*60+(int)m)%720)/720*2*pi;
    m=m/60*2*pi;
    n=fabs(h-m);
    n=sqrt(a*a+b*b-a*b*cos(n)*2.0);
    printf("%lf",n);
    return 0;
}