#include <bits/stdc++.h>
using namespace std;
int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double ans = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(abs(30 * (H + M / 60) - 6 * M) * M_PI / 180);
    printf("%.9f\n", sqrt(ans));
}