#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define PI 3.141592653589793
 
int main() {
  int a,b,h,m;
  cin >>a>>b>>h>>m;
  double r,r_a,r_b,d;
  r_b=(360*m)/60;
  r_a=(360*(60*h+m))/12*60;
  r=r_a - r_b;
  r=r*PI/180;
  d=sqrt(a*a+b*b-2*a*b*cos(r));
  cout<<d;