#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;

int main(){
  int a,b,h,m;
 static const double pi = 3.141592653589793;
  cin >> a >> b >> h >> m;
  double degree = abs(((double)h/12+(double)m/60/12))*360-((double)m/60*360);
//  cout << (double)2*a*b*cos(pi/180*degree) << endl;
//  cout << cos(pi/180*degree) << endl;
  printf("%.10f\n", (double)sqrt(a*a +b*b -2*a*b*cos(pi/180*degree)));
}

