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

#define ll long long
#define MOD 998244353

int main(){
    long double a,b,h,m;
    scanf("%Lf %Lf %Lf %Lf", &a, &b, &h, &m);
    // end input

    long double theta = (h/12.0 - 11*m/720.0) * 2*M_PI;
    long double d2 = a*a + b*b - 2*a*b*cos(theta);
    long double d = sqrt(d2);
    printf("%20.20Lf\n\n", d);

    return 0;
}