#include <bits/stdc++.h>
int main() {
  constexpr std::double_t pi = 3.1415926535;
  std::uint16_t a, b, h, m;
  std::cin >> a;
  std::cin >> b;
  std::cin >> h;
  std::cin >> m;
  std::double_t deg_h, deg_m;
  deg_m = 6 * m;
  deg_h = (30 * h) + ((std::double_t)m / 60 * 30);
  std::double_t diff_deg;
  diff_deg = deg_h - deg_m;
  if ((deg_m - deg_h) < diff_deg) diff_deg = deg_m - deg_h;
  std::double_t tan_length, sin_length;
  tan_length = h * std::tan(diff_deg / 180 * pi);
  sin_length = std::abs(h * std::sin(diff_deg / 180 * pi) - m);
  std::double_t ans;
  ans = std::sqrt((tan_length * tan_length) + (sin_length * sin_length));
  std::cout << ans;
  return 0;
}
