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

int main() {
  int a,b,h,m;
 cin>>a>>b>>h>>m;
  double d=abs(30*h-5.5*m);
  double r=d*M_PI/180.0;
  cout << fixed << setprecision(20);
cout<<sqrt(a*a+b*b-2*a*b*cos(r))<<endl;
}