#include <bits/stdc++.h>
int main(int argc, char** argv) {
  int A, B, H, M;
  double_t A_r, B_r;
  std::pair<double_t, double_t> A_v, B_v;
  static const double_t pi = 3.1415926535;
  std::cin >> A >> B >> H >> M;
  B_r = M / 60.0;
  A_r = (H + B_r) / 12.0;
  A_r *= pi * 2;
  B_r *= pi * 2;
  A_v = std::pair<double_t, double_t>(A * std::sin(A_r), A * std::cos(A_r));
  B_v = std::pair<double_t, double_t>(B * std::sin(B_r), B * std::cos(B_r));
  std::cout << std::sqrt(std::pow(A_v.first - B_v.first, 2.0) +
                         std::pow(A_v.second - B_v.second, 2.0))
            << std::endl;
  return 0;
}
