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

int main(){
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    printf("%.20lf\n",sqrt(pow(b,2.0) + pow(a,2.0) - 2.0 * b * a * cos((M_PI / 180.0) * fabs(30.0 * h - 6.0 * m))));
    return 0;
}