#include<stdio.h>
#include<math.h>
int main()
{
double a,b,H,M,ans,X;
  
  scanf("%lf %lf %lf %lf",&a,&b,&H,&M);
  
double pi=M_PI;
double rad=(30*H-5.5*M)*pi/180;
  
X=a*a+b*b-cos(rad);
  
  ans=sqrt(X);
  
  
  printf("%.10lf",ans);
  
return 0;
}