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

int main() {
    int A, B, H, M;
    double Hangle, Mangle, angle, SQ_C, C;
    scanf("%d %d %d %d", &A, &B, &H, &M);
    Hangle = (H * 30) + (M * 0.5);
    Mangle = 6 * M;
    if (Hangle > Mangle) {
        angle = Hangle - Mangle;
    } else {
        angle = Mangle - Hangle;
    }
    SQ_C = (A * A) + (B * B) - 2 * A * B * cos(angle * 3.14159265359 / 180);
    C = sqrt(SQ_C);
    printf("%.16f", C);
    return 0;
}