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

#define PI 3.14159265358979323846264338327950L

int main() {
    int a, b, h, m, dm;
    long double dh, d, ans;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    // 1min 6dig
    dh = 30 * h + 0.5 * m;
    dm = 6 * m;
    d = (PI * fabsl(dh - dm)) / 180;
    ans = sqrtl(a * a + b * b - 2 * a * b * cosl(d));
    printf("%20.20Lf\n", ans);
    return 0;
}