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

#define PI 3.14159265358979323846264338327950L

int main()
{
  int A,B,H,M;
  long double c,d,x,y;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&H);
  scanf("%d",&M);
  c=(60*H+M)*PI/360;
  d=(60*H+M)*PI/30;
  y=(long double)(A*A+B*B)-(long double)(2*A*B*cos(c-d));
  x=sqrtl(y);
  printf("%20.20Lf\n",x);
  return 0;
}
