#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double teta = (((60 * h + m) / 720) - (m / 60)) * 2 * M_PI;
  double res = pow(a * a + b * b - 2 * a * b * cos(teta), 0.5);
  cout << res << endl;
  return 0;
}
