#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double deg = 0.0;
  int min = h * 60 + m;
  if (0.5 * min > 6 * m) {
    deg = 0.5 * min - 6 * m;
    if (deg == 180.0) {
      double ans1 = a + b;
      cout << fixed << setprecision(20) << ans1 << endl;
    }
  } else if (0.5 * min < 6 * m) {
    deg = 6 * m - 0.5 * min;
    if (deg == 180.0) {
      double ans2 = a + b;
      cout << fixed << setprecision(20) << ans2 << endl;
    }
  } else if (0.5 * min == 6 * m) {
    if (a >= b) {
      cout << fixed << setprecision(20) << a - b << endl;
    } else {
      cout << fixed << setprecision(20) << b - a << endl;
    }
    return 0;
  }
  double rad = deg / 180.0 * 3.1415926545;
  ;
  double x = cos(rad);
  double y = sin(rad);
  double ans = pow((a * y) * (a * y) + (a * x - b) * (a * x - b), 0.5);
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}
