#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hv = 2 * M_PI / (12.0 * 60);
  double mv = 2 * M_PI / (60.0);
  double hr = hv * (h * 60 + m);
  double mr = mv * m;
  double diff = fabs(hr - mr);
  if (diff > M_PI) {
    diff = M_PI - diff;
  }
  double c_sq = a * a + b * b - 2 * a * b * cos(diff);
  cout << std::fixed << std::setprecision(15) << sqrt(c_sq) << endl;
  return 0;
}
