#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    long double a,b,h,m,A,B,C,ans;
    scanf("%Lf%Lf%Lf%Lf",&a,&b,&h,&m);
    A=(30.0*h)+(m/2.0);
    B=360.0-(6*m);
    C=360-(A+B);
    ans=(b*b)+(a*a)-2*b*a*cos(C);
    ans=sqrt(ans);
    printf("%Lf",ans);
}
