#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << fixed << setprecision(21);
  double A, B, h, m, n;
  cin >> A >> B >> h >> m;
  double a = (60 * h + m) * 3.141592653589793238462643383279 / 360;
  double b = m * 3.141592653589793238462643383279 / 180;
  double c = abs(a - b);
  n = A * A + B * B - 2 * A * B * cos(c);
  cout << sqrt(n);
}
