#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950
#define pow2(a) a*a


int main(){
  double a,b,h,m;
  long double c;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  double abrad = h*30 + m/2 -m*6;
  if(abrad <0) abrad *= -1;
  if(abrad >180) abrad =360 -abrad;
  abrad = abrad * PI /180;
  c = sqrt(pow2(a)+pow2(b)-(2*a*b)*cos(abrad));
  //printf("%lf %lf \n",pow2(a),pow2(b));
  printf("%20.20llf",c);
}