#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define pi 3.1415926535897932384626433832
double radian(double n)
{
    return (pi*(n/180.0));
}
int main()
{
    double a,b,h,m,minx,miny,hx,hy;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    minx=b*cos(radian(m*(360.0/60.0)));
    miny=b*sin(radian(m*(360.0/60.0)));
    hx=a*cos(radian((h+(m/60.0))*30.0));
    hy=a*sin(radian((h+(m/60.0))*30.0));
    double ans=sqrt(((hx-minx)*(hx-minx))+((hy-miny)*(hy-miny)));
    printf("%.20lf",ans);
}
