#include<bits/stdc++.h>
using namespace std;
int main(){
 long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double c,d,x;
  x=60*h+m;
  c=x/(12*60);
  d=x/60;
  long double ans;
  ans=a*a+b*b-2*a*b*cosl((c-d)*2*M_PI);
  cout<<std::fixed<<std::setprecision(12)<<sqrt(ans)<<endl;
  }