#include<stdio.h>
#define pi 3.1415926
#include<math.h>
#include<stdlib.h>
int main()
{
    int a,b,h,m;
    double theta,res;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    theta=abs(30*h-(11/2.0*m));
    res=a*a+b*b-2*a*b*cos((pi/180)*theta);
    printf("%.6lf\n",sqrt(res));
    return 0;


}
