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


int main(){
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    printf("%.15lf\n",sqrt(a*a+b*b-2*a*b*cos((h/12-m/60)*2*M_PI+(m/60*M_PI)/6)));
    return 0;
}