#include<stdio.h>
#include<math.h>
int main(){
double a,b,h,m,deg,pi=3.1415926535987932385;
scanf("%lf%lf%lf%lf", &a,&b,&h,&m);
 // if(6.0*m<30*h+m/2.0){}
  printf("%lf\n",sqrt(a*a+b*b-2*a*b*cos(2*pi/360.0*(6.0*m-30*h-m/2.0))));
return 0;
}