#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  std::cin >> a >> b >> h >> m;
  static const double pi = 3.141592653589793;
  std::cout << std::fixed;
  double rad_h = ((30 * h + 0.5 * m) / 180) * pi;
  double rad_m = (6 * m / 180) * pi;
  double x_h = a * sin(rad_h);
  double y_h = a * cos(rad_h);
  double x_m = b * sin(rad_m);
  double y_m = b * cos(rad_m);
  double length = sqrt((x_h - x_m) * (x_h - x_m) + (y_h - y_m) * (y_h - y_m));
  std::cout << setprecision(10) << length << '\n';
}
