#include <stdio.h>
#include <math.h>
int main(){
  double a,b,h,m;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  if(a<1||a>1000||b<1||b>1000||h<0||h>11||m<0||m>59)
  return 0;
  double mrad,hrad,sa;
  mrad = 6*m;
  hrad = (h*60+m)*0.5;
  if(mrad-hrad==0){
    if(a>b){
      a-=b;
    }else{
      a=b-a;
    }
    printf("%lf\n",a);
  }else if(mrad-hrad>0){
    sa=mrad-hrad;
    printf("%lf\n",sqrt(a*a+b*b-2*a*b*cos(sa)));
  }else{
    sa=hrad-mrad;
    printf("%lf\n",sqrt(a*a+b*b-2*a*b*cos(sa)));
  }
  return 0;
}
