#include <bits/stdc++.h>
int main() {
  int a, b, h, m;
  double theta, res;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  theta = abs(30 * h - (11 / 2.0 * m));
  res = a * a + b * b - 2 * a * b * cos((3.141592653589793 / 180) * theta);
  printf("%.10lf\n", sqrt(res));
  return 0;
}
