#include <bits/stdc++.h>
using namespace std;
int main() {
  double A;
  double B;
  double H;
  double M;
  double k;
  double t;
  double l;
  double p = 3.14159265358979323846264338;
  cin >> A;
  cin >> B;
  cin >> H;
  cin >> M;
  H = H + M / 60;
  k = (30.000000000000000 * H - 6.0000000000000000 * M) * p /
      180.00000000000000;
  t = A * A + B * B - 2 * A * B * cos(k);
  double d = pow(t, 0.500000000000000000);
  cout << fixed << setprecision(17) << d << endl;
}
