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

