#include <bits/stdc++.h>
using namespace std;
int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  if (h == 12) h = 0;
  if (m == 60) m = 0;
  long double x = 0.5 * (h * 60 + m);
  long double y = 6 * m;
  long double z = abs(x - y);
  z = min(z, 360 - z);
  double pi = 2 * acos(0.0);
  long double r = sqrt((a * a) + (b * b) - (2 * a * b * cos(z * pi / 180)));
  cout << fixed << setprecision(15) << r << endl;
}
