#include <bits/stdc++.h>
using namespace std;
static const double pi = 3.14159265358979323846264338327950288;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hAng = floor(h) * 30 + m / 60.0 * 30;
  double mAng = m / 60.0 * 360;
  while (hAng >= 360) {
    hAng -= 360;
  }
  while (mAng >= 360) {
    mAng -= 360;
  }
  double ang = min(abs(hAng - mAng), abs(-hAng + mAng));
  ang = ang / 180.0 * pi;
  double hyp = pow(a * a + b * b - 2 * a * b * cos(ang), 0.5);
  printf("%.10f", hyp);
  return 0;
}
