#include <stdio.h>
#include <math.h>
#define abs(x) ((x)<0 ? -(x) : (x))
#define PI 3.1415926535897

int main(){
  double a, b;  scanf("%lf %lf", &a, &b);
  int h, m;  scanf("%d %d", &h, &m);

  double radi = (double)abs((m*0.5+h*30) - (m*6));
  long double coss = cosl(PI * radi/180);

  long double ans = (long double)(a*a + b*b - 2*a*b*coss);
  ans = sqrtl(ans);
  
  printf("%.14Lf\n", ans);
  return 0;
}
  
  
