#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC168D
//ABC168C
int main(void) {
  double a, b, c, h, m, n, theta=0;
  int k, i, cou=0, tmp;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

  theta=fabs(m*6-h*30-m/2);
 // printf("%lf\n",theta);
  while(theta>360)theta-=360;
  theta=theta*M_PI/180;
  //printf("%lf\n",theta);
  //printf("%lf\n",cos(theta));
  c=pow(-2*a*b*cos(theta)+a*a+b*b, 0.5);
  printf("%.10lf", c);
  return 0;
}