#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double x, r;
  r = ((2 * 3.14159265358979323846 * H * 60) +
       (2 * 3.14159265358979323846 * M) +
       (2 * 3.14159265358979323846 * (60 - M) * 12)) /
      (12 * 60);
  if (r > (2 * 3.14159265358979323846)) {
    r -= (2 * 3.14159265358979323846);
  }
  x = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(r));
  cout << x << endl;
  return 0;
}
