#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

int main(){
    int A, B, H, M;
    scanf("%d%d%d%d", &A, &B, &H, &M);
    int dt;
    dt = (H * 30 - M * 6 >= 0) ? H * 30 - M * 6 : M * 6 - H * 30;
    double C;
    C = A * A + B * B - 2 * A * B * cos(dt *2*3.14/ 360);
    C = sqrt(C);
    printf("%lf", C);
    printf("%lf", PI);

    return 0;
}