#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 arg;
    long double c;

    arg = PI * ((h * 60 + m) / 2 - m * 6) / 180;
    c = sqrtl(a * a + b * b - 2 * a * b * cos(arg));

    printf("%20.20Lf", c);
    }