#include <bits/stdc++.h>
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  static const double pi = 3.141592653589793;
  int a = in(), b = in(), h = in(), m = in();
  double tmp1 = (double)360 * h / 12 + (double)30 * m / 60;
  double tmp2 = (double)360 * m / 60;
  double theta = abs(tmp1 - tmp2);
  double tmp3 = cos(pi * theta / 180);
  double ans = sqrt(a * a + b * b - 2 * a * b * tmp3);
  cout << std::fixed << std::setprecision(10) << ans << endl;
  return 0;
}
