#include <bits/stdc++.h>
int main() {
  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double dgreeh = 30.0 * h + m / 2;
  double dgreem = 6.0 * m;
  double dgree;
  if (dgreeh > dgreem) {
    dgree = dgreeh - dgreem;
  } else {
    dgree = dgreem - dgreeh;
  }
  if (dgree > 180) {
    dgree = 360 - dgree;
  }
  double rad = dgree * (3.14159265 / 180);
  double result = a * a + b * b - 2 * a * b * cos(rad);
  result = sqrt(result);
  printf("%f\n", result);
  return 0;
}
