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

int main(){
float a,b,h,m,c,n;

scanf("%f""%f""%f""%f",&a,&b,&h,&m);

n = (6*m - 30*h - m/2)*3.14159265358979/180;

c = a*a + b*b -  2*a*b*cos(n);

printf("%.20f",sqrt(c));

return 0;

}