#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

int main(void)
{
  int a, b, h, m;
  double ans, angle;
  double min, hour; //1分あたりの各速度

  min = 360 / 60;
  hour = (double)360 / 720;

  scanf("%d%d%d%d", &a, &b, &h, &m);
  min = min * m;
  hour = hour * (h * 60 + m);
  if (min > hour)
    angle = min - hour;
  else
    angle = hour - min;

  ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle * (M_PI / 180))));

  printf("%.12lf\n", ans);

  return 0;
}
