#include <stdio.h>
#include <math.h>
int main(){
  double A, B, H, M, Hd, Md, dd, C;
  scanf("%lf %lf %lf %lf", &A, &B, &H, &M);
  Hd = (H/6)*M_PI + (M/360)*M_PI;
  Md = (M/30)*M_PI;
  dd = Hd - Md;
  C = sqrt(pow(A,2) + pow(B,2) - 2*A*B*cos(dd));
  printf("%.9lf", C);
  return 0;
}