#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, h, m;
  cin >> a >> b >> h >> m;
  double hd = double(h);
  double md = double(m);
  double hAngle = (hd * 30.f) + (md / 60.f * 30.f);
  double mAngle = md * 6.f;
  double angleDiff = abs(hAngle - mAngle);
  if (angleDiff > 180.f) {
    angleDiff = 360.f - angleDiff;
  }
  double ad = double(a);
  double bd = double(b);
  double rad = angleDiff * M_PI / 180.f;
  double sqrAns = (ad * ad) + (bd * bd) - (cos(rad) * (2 * ad * bd));
  double ans = sqrt(sqrAns);
  cout << fixed << setprecision(20) << ans;
  return 0;
}
