#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
  
 long double a,b,h,m;
 long double d1,d2,xs,ys,xl,yl;
 long double PI,dis;
  PI=3.141592653589793238462643L;
  
  scanf("%Lf %Lf %Lf %Lf",&a,&b,&h,&m);
  
  xs=a*(long double)sin(PI*(30.0L*h+m/2.0L)/180.0L);
  
  
  ys=a*(long double)cos(PI*(360.0-30.0L*h+m/2.0L)/180.0L);
  
  xl=b*(long double)sin(PI*(6.0L*m/180.0L));
  yl=b*(long double)cos(PI*(6.0L*m/180.0L));
  
  //printf("%.30Lf\n",xs);
  //printf("%.30Lf\n", (long double)cos((30.0L*h+m/2.0L)/180.0*PI ));
  //printf("%.30Lf\n",xl);
  //printf("%.30Lf\n",yl);
  
  dis=(long double)pow((long double)pow((xs-xl),2L)+(long double)pow((ys-yl),2L),0.5L);
  
  
  printf("%.30Lf",dis);
  
  return 0;
}