#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double a, b, h, m;
  scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
  double rh = 2.0 * 3.14159265358979323846264338327950 / 12.0;
  double rm = 2.0 * 3.14159265358979323846264338327950 / 60.0;
  double rad = abs(rh * h + m * rh / 60 - rm * m);
  rad = min(rad, abs(rad - 2 * 3.14159265358979323846264338327950));
  if (rad < 1e-9) {
    printf("% .20lf\n", 0);
  } else {
    printf("%.20lf\n", sqrt(a * a + b * b - 2.0 * a * b * cos(rad)));
  }
}
