#include <bits/stdc++.h>
using namespace std;
int main() {
  long double pi =
      3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692;
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  int rm;
  rm = M * 6;
  double rh;
  rh = (H * 60 + M) / 2;
  double angle;
  angle = abs(rm - rh);
  cout << fixed << setprecision(20)
       << static_cast<long double>(
              sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(pi * angle / 180)))
       << endl;
  return 0;
}
