#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338

int main(){
    int a,b,h,m;

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

    double argh, argm, arg;
    long double c;
    argh = (h * 60 + m) / 2;
    argm = m * 6;
    if(argh == argm){
        c = abs(a-b);
    }else if(argh > argm){
        arg = argh - argm;
        c = sqrt(a * a + b * b - 2 * a * b * cos(PI / 180 * arg));

    }else{
        arg = argm - argh;
        c = sqrt(a * a + b * b - 2 * a * b * cos(PI / 180 * arg));

    }
    printf("%.10Lf", c);
    }