#include <bits/stdc++.h>
using namespace std;
int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double angle = 6 * abs(m - (h * 5 + (long double)5 * m / 60.0));
  if (angle > 180) angle -= 180;
  long double c = sqrt((long double)(b * b) + (long double)(a * a) -
                       2 * b * a * cos(angle * M_PI / 180));
  std::cout << std::setprecision(10);
  cout << c << endl;
  return 0;
}
