#include <bits/stdc++.h>
int main() {
  std::uint64_t a, b, h, m;
  std::cin >> a;
  std::cin >> b;
  std::cin >> h;
  std::cin >> m;
  long double deg_h, deg_m;
  deg_m = 6 * m;
  deg_h = ((std::double_t)30 * h) + (0.5 * (std::double_t)m);
  long double diff_deg;
  diff_deg = deg_h - deg_m;
  if (360 - diff_deg < diff_deg) diff_deg = 360 - diff_deg;
  long double sin_length, cos_length;
  sin_length =
      (long double)a * std::sin(diff_deg / 180 * 3.14159265358979323846);
  cos_length =
      (long double)a * std::cos(diff_deg / 180 * 3.14159265358979323846) - b;
  long double ans;
  ans = std::sqrt((sin_length * sin_length) + (cos_length * cos_length));
  std::cout << ans;
  return 0;
}
