#include <bits/stdc++.h>
using namespace std;
int main() {
  long double A, B, H, M, hk, mk, k, ans;
  cin >> A >> B >> H >> M;
  mk = M * 6;
  hk = (H * 60 + M) * 0.5;
  k = fabs(hk - mk);
  if (k > 180) {
    k = k - 180;
  }
  k = k * (2 * M_PI / 360);
  ans = 2 * A * B * cos(k);
  A = A * A;
  B = B * B;
  ans = A + B - ans;
  ans = sqrt(ans);
  printf("%.10Lf\n", ans);
}
