#include<stdio.h>
#include<math.h>
#define s(n) (n)*(n)
int main() {
  double A,B,H,M,a,b,omega;
  scanf("%lf%lf%lf%lf",&A,&B,&H,&M);
  a=((H+M)/12)*2;
  b=(M/60)*2;
  if(a-b<1){
    omega=a-b;
  }else{
    omega=2-(a-b);
  }
  printf("%f",sqrt(s(A)+s(B)-2*A*B*cos(omega*M_PI)));
  return 0;
}