#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950L  // 円周率

using namespace std;

int main()
{
    // 時針と分針の値から角度を計算する
    //3 4 9 0
    //3 4 10 40

    long double A, B, H, M;
    cin >> A >> B >> H >> M;

    long double hAngle, mAngle, angle;

    hAngle = ((long double)H * 30.0)+((long double)M * 0.5);
    mAngle = (long double)M * 6.0;

    if ((long double)M/5 > H) {
        angle = (long double)mAngle - (long double)hAngle;
    }
    else {
        angle = (long double)hAngle - (long double)mAngle;
    }
    
    if (angle > 180.0) {
        angle = 360.0 - (long double)angle;
    }

    //cout << angle << "\n";

    // 余弦定理で頂点の長さを計算する
    // a2 = b2 + c2−2bccosA

    long double radian = angle * PI / 180.0;
    long double rad = PI * 2 * ((long double)H / 12.0 + ((long double)M / 60.0) / 12.0 - (long double)M / 60.0);
    long double output = pow(A, 2.0) + pow(B,2.0) - (2.0 * A * B * cos(radian));
    long double rsq = (long double)(A * A + B * B) - (long double)(2 * A * B) * cosl(rad);

    cout << sqrtl(rsq) << endl;

    return 0;
}
