#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double t=acos(-1)*(11.0*m-60.0*h)/360.0;
  double L=sqrt(a*a+b*b-2*a*b*cos(t));
  cout<<fixed<<setprecision(11)<<L<<endl;
}
 