#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  H *= 60;
  int m = M * 6;
  int h = (H + M) / 2;
  int S = h - m;
  long double c = sqrt(A * A + B * B - 2 * A * B * cos(S * M_PI / 180));
  if (c * c > A * A + B * B - 2 * A * B * cos(S * M_PI / 180)) {
    c -= 0.000000001;
  }
  if (c * c < A * A + B * B - 2 * A * B * cos(S * M_PI / 180)) {
    c += 0.000000001;
  }
  cout << fixed << setprecision(20) << c << endl;
}
