/* C - : (Colon) */

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

int main(void){
  int A, B, H, M;
  double angle, dist;
  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);
}
