#include <stdio.h>
#include <math.h>

int main() {
  double a, b, h, m, deg, ans;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    
  //c2=a2+b2−2ab*cos𝐶
  deg = fabs((11*m-60*h)*M_PI/360);
  ans = sqrt(a*a + b*b - 2*a*b*cos(deg));
  
  printf("%lf", ans);
  return(0);
}