#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double Aangle = H * 30 + (double)M * 0.5;
  double Bangle = M * 6;
  double angle;
  long double radian;
  angle = Aangle - Bangle;
  if (180 < angle) {
    angle = 360 - angle;
  } else if (-180 < angle && angle < 0) {
    angle = 0 - angle;
  } else if (angle < -180) {
    angle = -180 - angle;
  }
  radian = angle * 3.14159265358979323846264338327950L / 180.0;
  cout << setprecision(15) << sqrt(A * A + B * B - 2 * A * B * cos(radian))
       << endl;
}
