#include <bits/stdc++.h>
using namespace std;
int main() {
  long double a = 0, b = 0, h = 0, m = 0;
  cin >> a >> b >> h >> m;
  long double ab = 0, length = 0;
  ab = abs((m * 6) - (h * 30 + m / 2.0));
  if (ab > 180) ab = ab - 180;
  length = sqrtl(
      (a * a + b * b) -
      (2 * a * b * cosl(ab * 3.14159265358979323846264338327950L / 180.0)));
  printf("%20.20Lf\n", length);
  return 0;
}
