#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = 2 * acos(0.0);
  double th = 0.5 * m + 30 * h - 6 * m;
  if (th < 0) th = -th;
  double c;
  c = a * a + b * b - 2 * a * b * cos(th * pi / 180);
  c = sqrt(c);
  printf("%.20f", c);
}
