#include<stdio.h>
#include<math.h>
const double hRAD=0.00872664625997164773718584029893463593907654285431L;
signed main(void)
{
  int A,B,H,M;
  if(~scanf("%d %d %d %d",&A,&B,&H,&M))
  {
    double theta=(60*H-11*M)*hRAD,x=A-B*cos(theta),y=B*sin(theta);
    return printf("%.20f",sqrt(x*x+y*y)),0;
  }
}