#include <bits/stdc++.h>
int main() {
  double A, B, H, M;
  double r;
  std::cin >> A >> B >> H >> M;
  H = (H * 60 + M) * .5;
  H > M* 6 ? r = H - M* 6 : r = M * 6 - H;
  if (r > 180) {
    r = 360 - r;
  }
  if (r == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  r = (r * M_PI) / 180.0;
  std::cout << (sqrt((double)(A * A + B * B) -
                     (double)(2 * A * B) * (double)cos(r)))
            << std::endl;
  return 0;
}
