#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double pi = M_PI;
  long double rad = abs(pi / 30 * m - (pi / 360 * m + h * pi / 6));
  if (rad > pi) rad = 2 * pi - rad;
  long double ans = a * a + b * b - 2 * a * b * cos(rad);
  printf("%20.20Lf\n", sqrt(ans));
}
