#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const double pi=3.1415926535897;
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    cout<<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos((30*h+(m/2)-6*m)/180*pi));
    
}