#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double rad = (H*30 + M*0.5 - M*6)*M_PI/180.0;
    double ans = sqrt(A*A + B*B -2.0*A*B*cos(rad));
    printf("%10.10f\n", ans);

    return 0;
}