#include<bits/stdc++.h>
using namespace std;

int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double pi=acos(-1);
    double ha=(h*60+m)*0.5;
    double ma=m*6;
    double angle=abs(ha-ma);
    printf("%.9lf",sqrt(a*a+b*b-2*a*b*cos(angle*pi/180)));
}