// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

double dmax(double x, double y){
    if(x < y) return y;
    return x;
}

int main() {
    int i,j;
    int n;

    double a ,b;
    double h,m;

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

    double ans;
    double hdeg = h * 30.0 + (m/60) * 30;
    double mdeg = m / 5.0 * 30.0;
    double deg;

    deg = dmax(hdeg-mdeg, mdeg-hdeg);
    if(deg > 180) deg = 360-deg;

    //printf("hdeg: %f, mdeg:%f, deg:%f\n", hdeg, mdeg, deg);
    if(deg == 180){
        ans = a+b;
    }else if(deg == 0){
        ans = dmax(a-b,b-a);
    }else{
        double rad = deg * 3.141592653589793 / 180;
        ans = (a*a) + (b*b) - (2 * a * b * cos(rad));
        ans = sqrt(ans);
        //printf("%f %f %f\n",a*a, b*b, 2 * a * b * cos(rad));
        //printf("rad:%f\n", rad);
    }

    printf("%.10f", ans);
    return 0;

}