#include <iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;

int num[10005];

void debugout ( long long value ){
    cout << value  << endl;
}


int main(){

    long double hourLength, minuteLength, hour, minute;
    cin >> hourLength >> minuteLength >> hour >> minute;

    long double PI = 3.141592653589793238462;

    long double theta = 2*PI*( hour/12.0 + minute/720.0 - minute/60.0);

    double length = ( hourLength*hourLength + minuteLength*minuteLength )
            - (long double)2.0 * hourLength * minuteLength * cos(theta);

    printf("%10.10lf", sqrt(length));
    return 0;
}



