#include <bits/stdc++.h>
using namespace std;
int a, b, h, m, ans, sz, fz, j;
int main() {
  cin >> a >> b >> h >> m;
  sz = (60 * h + m) * 0.5;
  fz = 6 * m;
  j = abs(sz - fz);
  if (j > 180) j = 360 - j;
  ans = cos(j * M_PI / 180);
  printf("%.20f", sqrt(a * a + b * b - 2 * a * b * ans));
  return 0;
}
