#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long double a, b, h, m;
  long double ans = 0, rad = 0, pi = 3.14159265359;
  cin >> a >> b >> h >> m;
  h *= 30;
  m *= 6;
  rad = abs(h - m);
  (360 - rad < rad)
      ? ans = (double)a * (double)a + (double)b * (double)b -
              2 * (double)a * (double)b * cos(pi * ((360 - rad) / 180))
      : ans = (double)a * (double)a + (double)b * (double)b -
              2 * (double)a * (double)b * cos(pi * (rad / 180));
  cout << fixed << setprecision(15) << sqrt(ans);
  return 0;
}
