#include <iostream>

using namespace std;

int main()
{
  int a, b, h, m;
  float angleH, angleM, diffAngle, distance;
  cin >> a >> b >> h>>m;
  angleH = h * 360 / 12;
  angleM = m * 6;
  diffAngle = abs(angleH - angleM);
  distance = pow(a * a + b*b - 2 * a * b * cos(diffAngle), 0.5);
  cout << distance;
  return 0;
}