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

int main(void){
    int A, B, H, M;
    scanf("%d %d %d %d", &A, &B, &H, &M);
    double kA, kB;
    kA = 0.5 * (60 * H + M);
    kB = 6 * M;
    double kgap;
    kgap = kA > kB ? kA - kB : kB - kA;
    kgap = 180 < kgap ? 360 - kgap : kgap;
    kgap = M_PI / 180 * kgap;
    double x = cos(kgap);
    
    double answer = A * A + B * B - 2 * A * B * x;
    answer = sqrt(answer);
    printf("%5.9f", answer);
    
    return 0;

}
