#include <bits/stdc++.h>
using namespace std;
int H, M, A, B;
int main() {
  std::cin >> A;
  std::cin >> B;
  std::cin >> H;
  std::cin >> M;
  double x_A = A * sin((H / 12. + M / 720.) * 2. * M_PI);
  double y_A = A * cos((H / 12. + M / 720.) * 2. * M_PI);
  double x_B = B * sin(M / 60. * 2. * M_PI);
  double y_B = B * cos(M / 60. * 2. * M_PI);
  double len = sqrt(std::pow(x_B - x_A, 2.) + std::pow(y_B - y_A, 2.));
  std::cout << std::setprecision(16) << len;
}
