/* C - : (Colon) */

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

int main(void){
  int A, B, H, M;
  // double angle, dist;
  double angle1, angle2, x1, y1, x2, y2;
  scanf("%d %d %d %d", &A, &B, &H, &M);
  /*
  angle = 30 * H + 0.5 * M - 6 * M;
  if(angle < 0) angle = 0 - angle;
  //angle %= 360;
  //if(angle > 180) angle -= (angle - 180) * 2;
  dist = sqrt(A * A + B * B - 2 * A * B * cos(angle * M_PI / 180));
  printf("%f\n", dist);
  */
  angle1 = 30 * H + 0.5 * M;
  angle2 = 6 * M;
  x1 = A * cos(angle1 * M_PI / 180);
  y1 = A * sin(angle1 * M_PI / 180);
  x2 = B * cos(angle2 * M_PI / 180);
  y2 = B * sin(angle2 * M_PI / 180);
  printf("%f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
  return 0;
}
