#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);

    long double arg;
    long double c;

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

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