#include<stdio.h>
#include <math.h>
#define PI 3.141592653589793//double radian = degree * PI / 180.0;
int main()
{

   int a,b,h,m;
   scanf("%d %d %d %d",&a,&b,&h,&m);
   double a_x,a_y,b_x,b_y;
    a_x=a*cos((h*-30.0f+ m*-0.5f) *PI/180.0f);
    a_y=a*sin((h*-30.0f+ m*-0.5f) *PI/180.0f);
    
    b_x=b*cos(m*-6.0f *PI/180.0f);
    b_y=b*sin(m*-6.0f *PI/180.0f);
    //printf("%f %f %f %f",a_x,a_y,b_x,b_y);
    double length;
    length=sqrt((a_x-b_x)*(a_x-b_x)+(a_y-b_y)*(a_y-b_y));
    printf("%.9lf",length);
}