#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double hAngle, mAngle, angle;
  hAngle = (H * 30.0) + (M * 0.5);
  mAngle = M * 6.0;
  if (M / 5 > H) {
    angle = mAngle - hAngle;
  } else {
    angle = hAngle - mAngle;
  }
  if (angle > 180) {
    angle = 360.0 - angle;
  }
  long double radian;
  radian = angle * 3.14159265358979323846 / 180.0;
  long double output;
  output = sqrt((A * A + B * B) - (2.0 * A * B) * cos(radian));
  cout << output;
}
