#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    long double a,b,h,m,ans,ans1,kon;
    scanf("%Lf %Lf %Lf %Lf",&a,&b,&h,&m);
    kon=abs(30*h-11*m/2);
    if(kon>180)kon=180-kon;
    
    ans=a*a+b*b-2*a*b*cos(kon*2*acos(0.0)/180);
    ans1=(long double)sqrt(ans);
    printf("%.20Lf\n",ans1);
    return 0;
}