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

int main() {
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double pi=acos(-1);
  long double rad=(30*h+0.5*m-6*m)*pi/180;
  long double x=sqrt(a*a+b*b-2*a*b*cos(rad));
  printf("%.100Lf",x);
}