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

int main(void)
{
  int a, b, h, i, m, cl = 0;
  double A, B, C, y, result = 0;
  
  scanf("%d %d %d %d", &a, &b, &h, &m);
  
  cl = 60*h + m;
  
  A = (double)cl*0.5;
  B= m*6;
  if( A - B == 0 ){
    if( a > b ){
      printf("%d", a-b);
    } else {
      printf("%d", b-a);
    }
    return 0;
  }
  
  if( A - B == 180 ){
      printf("%d", a+b);   
    return 0;
  }
  
  if( A - B > 0 ){
      C = A-B;
  } else {
      C = B-A;
  }
  
  //printf("%ld\n", C);
  
  C = (double)C * M_PI/180;
  if( C > 180 ){
      C = 360 - C;
  }
  
  y = cos(C);
  
  result = (a*a) + (b*b) - (2*a*b*y);

  printf("%.15lf\n", pow(result, 0.5));
  return 0;
}