#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double tan=h*30+0.5*m;
  double tyo=m*6;
  double r=abs(tyo-tan);
  double ans=b*b+a*a-2*b*a*cos(M_PI/180.0*r);
  cout<<fixed<<setprecision(20)<<sqrt(ans);
}
