#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template <typename Type>
inline void chmin(Type& a, Type b) {
  if (a > b) a = b;
}
template <typename Type>
inline void chmax(Type& a, Type b) {
  if (a < b) a = b;
}
template <typename Type>
inline void sort(Type& arr) {
  std::sort(arr.begin(), arr.end());
}
template <typename Type>
inline Type nth(vector<Type>& arr, size_t pos) {
  std::nth_element(arr.begin(), arr.begin() + pos, arr.end());
  return arr[pos];
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll iA, iB, iH, iM;
  cin >> iA >> iB >> iH >> iM;
  ld A = ld(iA);
  ld B = ld(iB);
  ld H = ld(iH);
  ld M = ld(iM);
  ld dt = (H / 12.0 + M / (60.0 * 12.0) - M / 60.0) * 2.0 * M_PI;
  ld R2 = A * A + B * B - 2.0 * A * B * cosl(dt);
  ld R = sqrtl(R2);
  cout << std::setprecision(16) << R;
  return 0;
}
