#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  double ang, rad, ans;
  static const double pi = 3.141592653589793;
  cin >> a >> b >> h >> m;
  ang = 30 * h + 0.5 * m - 6 * m;
  if (ang == 0) {
    ans = b - a;
  } else if (ang < 180) {
    rad = ang * pi / 180;
    ans = pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(rad);
  } else if (ang > 180) {
    ang = 360 - ang;
    rad = ang * pi / 180;
    ans = pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(rad);
  } else {
    ans = a + b;
  }
  cout << fixed << setprecision(10) << sqrt(ans) << endl;
}
