#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#define lFF long double 

int main()
{
 double PI = acos(-1); 
 
 int A , B , H , M ;
 scanf("%d %d %d %d",&A,&B,&H,&M);
 
 double MinuteGrad = M * 6 ;
 
 double HourGrad = H * 30 + (double)((M*30))/60;

 double Angle = 360 - (HourGrad - MinuteGrad);
 double Ang  = (Angle * PI )/ 180;
 

 double AlKashi = sqrt(pow(A,2) + pow(B,2)- (2*A*B)*cos(Ang));
 
 printf("%.11lf",AlKashi); 
 
 
  return 0;
}
 

