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

#define GROW_DIFF_DEG 5.5
#define MIN_PER_HOUR 60
#define TERN_DEG 180
#define RAD 360
#define PI 3.141592653589793238

int main(void) {
  float a, b;
  int h, m;
  scanf("%f %f %d %d", &a, &b, &h, &m);

  int min = h * MIN_PER_HOUR + m;
  long double dig = (long double) GROW_DIFF_DEG * (long double) min;

  int count = 0;
  long double theta = 0;
  while (dig > TERN_DEG) {
    dig -= TERN_DEG;
    count++;
  }
  if (!(count % 2)) theta = dig * (long double) PI * (long double) 2 / (long double) RAD;
  else  {
    theta = ((long double) TERN_DEG - dig) * (long double) PI * (long double) 2 / (long double) RAD;
  }
  long double result_cos;
  if (dig != (double) 90 && dig != (double) 270) {
    result_cos = cosl(theta);
  } else {
    result_cos = 0;
  }
  long double double_s = pow((long double) a, (long double) 2) + pow((long double) b, (long double) 2) - (long double) 2 * (long double) a * (long double) b * result_cos;
  printf("%Lf\n", sqrtl(double_s));

  return 0;
}
