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

int main(){
  double A,B,H,M;
  double T=0;
  scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
  T=M/30.0*M_PI-(H*60+M)/360.0*M_PI;
  printf("%.10lf\n",sqrt(A*A+B*B-2.0*A*B*cos(T)));
  return 0;
}