#include <bits/stdc++.h>
using namespace std;
double rad(double x) { return x * acos(-1) / 180.0; }
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double hour_angle = (h / 12.0) * 360.0;
  double temp = m / 60;
  hour_angle += (temp / 12.0) * 360;
  double min_angle = (m / 60.0) * 360.0;
  double diff = (hour_angle - min_angle);
  if (diff >= 180) diff = diff - 180.0;
  if (diff < 0) diff += 180.0;
  double C = diff;
  double x = b * sin(rad(C));
  double y = a - b * cos(rad(C));
  double ans = sqrt(x * x + y * y);
  cout << fixed << setprecision(12) << ans << '\n';
}
