#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double h_d, m_d, pi, deg_r, ans_rad, ans;
  h_d = (h * 30 + m / 2);
  m_d = m * 6;
  pi = 3.14159265358979;
  deg_r = abs(h_d - m_d) * pi / 180;
  ans_rad = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(deg_r);
  ans = sqrt(ans_rad);
  cout << fixed << setprecision(10) << ans << endl;
}
