#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double angle = abs(((h * 30) + (30 * m / 60) - m * 6));
  if (angle > 360 - angle) angle = 360 - angle;
  if (angle == 0) {
    cout << "0";
    exit(0);
  }
  if (angle == 180) {
    cout << a + b;
    exit(0);
  }
  double ans = (a * a) + (b * b) - 2 * a * b * cos(angle * 3.14159265359 / 180);
  cout << setprecision(11) << sqrt(ans);
}
