#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
int main(){
 
  int a,b;
  int h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);
 
  double angle = abs( 30*h + 0.5*m - m * 6 );
  double rad;
    //rad = (angle /180)* M_PI;
 
  //printf("%.10f ",h);
  double ans = sqrt(a*a + b*b -2*a*b*cos((angle /180)* M_PI));
  printf("%.11f",ans);
 
  return 0;
}