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

int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double c = M_PI/6;
  long double d = M_PI/30;
  long double s;
  s = (a*a+b*b-2*a*b*cos(m*d*11.0/12.0-h*c));
  cout<<setprecision(20)<<sqrtl((long double)s)<<endl;
}
