#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
int main()
{
    /*long double t,a,b,c,d;
    cin>>a>>b>>c>>d;
    t=sqrt(a*a+b*b-2*a*b*abs(cosl(2*PI*((c/12.0)+(d/720.0)-(d/60.0)))));
    printf("%.20Lf",t);
    */
    int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));

}
