#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double h_arg = h * 30 + 0.5 * m;
  int m_arg = m * 6;
  double c;
  double arg = abs(h_arg - m_arg);
  if (0 < arg && arg < 180) {
    c = sqrt(a * a + b * b - 2 * a * b * cos(double((arg * M_PI) / 180)));
  } else if (arg > 180) {
    arg = arg - 180;
    c = sqrt(a * a + b * b - 2 * a * b * cos(double((arg * M_PI) / 180)));
  } else if (arg == 0) {
    c = abs(a - b);
  } else {
    c = a + b;
  }
  printf("%.10f\n", c);
  return 0;
}
