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

#define PI 3.141592653589793238462643383279 

int main() {
    int a, b, h, m;
    long double ans;
    long double deg;
    long double rad;
    scanf("%d %d %d %d", &a, &b, &h, &m);
    deg=fabsl((long double)(m*360/60-(h*60+m)*360/12/60));
    rad=deg*PI/180.0;
    ans=(long double)(a*a+b*b)-(long double)(2*a*b)*cosl(rad);
    printf("%20.20Lf\n", sqrtl(ans));
    return 0;
}