#include <iomanip>

#include "bits/stdc++.h"
using namespace std;
#define ld long double
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h * 60 + m;
    ld ha = (h % 720) / 2, ma = (h % 60) * 6;
    ld dif = abs(ha - ma);
    dif = min(dif, 360.0 - dif);
    dif *= acos(-1) / 180.0;
    ld c = a * a + b * b - 2 * a * b * cos(dif);
    cout << setprecision(20) << sqrt(c) << endl;
}

