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

int main()
{
    double a,b,h,m,degree,time,out;
    double pi = 3.141592653589793238462643383279502884197169399;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    time = 60*h+m;
    degree = abs((int)(6*time)%360-(int)(0.5*time)%360);
    if(degree>=180) degree = 360-degree;
    out = pow((pow(a,2)+pow(b,2)-2*a*b*cos(degree*pi/180)),0.5);
    printf("%.20lf\n",out);
    return 0;
}
