#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double pi=3.141592653589793;
    double rad=(30.0*h+m*0.5-m*6.0)*pi/180.0;
    rad=cos(rad);
    cout<< fixed <<setprecision(10);
cout<<pow(a*a+b*b-2*a*b*rad,0.50);
}


