#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  double a,b,c,h,m,theta;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  theta=fabs(11*m/2-30*h);
  theta*=M_PI/180;
  c=cos(theta);
  c=a*a+b*b-2*a*b*c;
  c=pow(c,0.5);
  printf("%.12lf\n",c);
  return 0;
}
