#include <bits/stdc++.h>
using namespace std;
int main(){
    double A,B, H ,M;
    cin >> A >> B>> H >> M;
    double a = 2 * M_PI* H/ 12, b = 2 * M_PI*M / 60;
    a += 2 * M_PI / 12 * M / 60; 
    double ans = A*A + B*B - 2* A* B * cos(a - b);
    printf("%.10lf\n", sqrt(ans));
}