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

double const pi = acos(-1);

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(10)
    << sqrt(a * a + b * b - 2 * a * b * cos(2 * pi * abs((h + m / 60) / 12.0 - m / 60.0))) << '\n';
}