#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

    double th,tm,t;
    tm=2*m*atan(1)/15;
    m=m+60*h;
    th=m*atan(1)/90;
    t=(th-tm);
    if(t<0)
    {
        t=-t;
    }
    if(t>4*atan(1))
    {
        t=8*atan(1)-t;
    }

    double ans;
    ans=a*a+b*b-2*a*b*cos(t);
    ans=sqrt(ans);

    printf("%f\n",ans);

    return 0;
}