#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main() {
  long long A, B, H, M;
  cin >> A >> B >> H >> M;
  long long h = 30 * H + M / 2.0;
  long long m = M * 6;
  double diff = min(abs(h - m), abs(m - h));
  diff *= pi / 180;
  cout << fixed << setprecision(20)
       << sqrt(A * A + B * B - 2 * A * B * cos(diff)) << '\n';
}
