#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
 double PI = acos(-1); 

 int A , B , H , M ;
 scanf("%d %d %d %d",&A,&B,&H,&M);

 int MinuteGrad = M * 6 ;
 int HourGrad = H * 30 + (M*30)/60;
 
 double Angle = abs(HourGrad - MinuteGrad);
 double Ang  = (Angle * PI )/ 180;
 double AlKashi = sqrt(pow(A,2) + pow(B,2)- (2*A*B)*cos(Ang) );

 printf("%.15lf",AlKashi); 


  return 0;
}
