#include <bits/stdc++.h>
using namespace std;
int main() {
  static const double pi = acos(-1);
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double X = (30 * H + 0.5 * M);
  double Y = (6 * M);
  double x1 = A * cos(pi / 2 - pi / 180 * X);
  double y1 = A * sin(pi / 2 - pi / 180 * X);
  double x2 = B * cos(pi / 2 - pi / 180 * Y);
  double y2 = B * sin(pi / 2 - pi / 180 * Y);
  double a = pow(x1 - x2, 2);
  double b = pow(y1 - y2, 2);
  double c = sqrt(a + b);
  cout << fixed << setprecision(10) << c << endl;
}
