#include <math.h>
int main()
{
  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  
  double l, s;
  l = h * 30 + m / 2;
  s = 6 * m;
  double c;
  c = sqrt(l * l + s * s - 2 * l * s * cos(fabs(l - s)));
  printf("%lf", c);
}