#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll        = long long;
using P         = pair<int, int>;
const double PI = acos(-1);

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double x  = double(H * 60 + M) / 720 * 2 * PI;
    double tx = double(M) / 60 * 2 * PI;
    double ph = A * cos(x), qh = A * sin(x);
    double pm = B * cos(tx), qm = B * sin(tx);
    double dx = ph - pm, dy = qh - qm;
    double ans = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}
