#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double theta = abs(2 * M_PI * (h / 12 + m / 60) - 2 * M_PI * m / 60);
  double r = sqrt(a * a + b * b - 2 * b * a * cos(theta));
  printf("%.20lf\n", r);
}
