#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double pi = acos(-1);
  long double angle_A = (60 * H + M) * pi / 360;
  long double angle_B = M * pi / 30;
  long double angle = angle_A - angle_B;
  long double x = sqrt(A * A + B * B - 2 * A * B * cos(angle));
  cout << fixed << setprecision(20) << x << endl;
}
