#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[]) {
    const double pi = 3.141592653589793;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double rad = 2*pi/12 * H + 2*pi/(12*60) * M - 2*pi/60 * M;
    double ans = A * A + B * B - 2 * A * B * cos(rad);
    printf("%.20f\n", sqrt(ans));
    return 0;
}

