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


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