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

#define pi  3.14159265358979323846

int main(){
  int a, b, h, m;
  long double atheta, btheta, abtheta;
  long double ans;
  scanf("%d%d%d%d",&a,&b,&h,&m);
  btheta = ((long double)m/60)*360;
  atheta = (((long double)h/12) + ((long double)m/(60*12)))*360;
  //printf("%Lf %Lf\n",atheta,btheta);
  
  if(abs(atheta - btheta) > 180) {
    abtheta = 360 - abs(atheta - btheta);
  }else {
    abtheta = abs(atheta - btheta);
  }
  
  //printf("%Lf\n",abtheta);
  
  ans = sqrtl( a*a + b*b - 2*a*b*cosl(abtheta*pi/180));
  printf("%.15Lf\n",ans);
  
  return 0;
}