#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double anglea = 30 * h + m / 2;
  double angleb = 6 * m;
  double angle = min(max(anglea, angleb) - min(anglea, angleb),
                     360 - max(anglea, angleb) + min(anglea, angleb));
  double x = (a * a + b * b - 2 * a * b * cos(M_PI / (180 / angle)));
  double ans = sqrt(x);
  cout << fixed << setprecision(15);
  cout << ans << endl;
  return 0;
}
