#include <bits/stdc++.h>
using namespace std;
int main() {
  static const double pi = 3.141592653589793;
  std::cout << std::fixed;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  cout << sqrt(a * a + b * b -
               2 * a * b * cos(pi * (30 * (h + m / 60) - 6 * m)) / 180)
       << endl;
}
