#include<stdio.h>
#include<math.h>
int main(){
  int a,b,h,m;
  double as,bs,work,s;
  scanf("%d%d%d%d",&a,&b,&h,&m);
  as=h*360.0/12.0+m*360.0/12.0/60;
  bs=m*360.0/60.0;
  if(as<bs){
    work=as;
    as=bs;
    bs=work;
  }
  s=as-bs;
  if(s>180)s=360-s;
  printf("%lf\n",sqrt((double)(a*a+b*b)-2.0*a*b*cos(M_PI/180.0*s)));
  return 0;
}