#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  static const double pi = 3.141592653589793;
  double hh = 30 * h + 0.5 * m;
  double mm = 6 * m;
  double theta = (abs(hh - mm) * pi) / 180;
  double c = cos(theta);
  double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * c);
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}
