#include <bits/stdc++.h>
using ll = long long;
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 A, B, H, M;
  cin >> A >> B >> H >> M;
  using ld = double;
  ld hd = ld(H / ld(12.0) + ld(M) / (ld(60.0) * ld(12.0))) * ld(2.0) * ld(M_PI);
  ld md = ld(M / ld(60.0)) * ld(2.0) * ld(M_PI);
  ld ax = ld(A) * cos(hd);
  ld ay = ld(A) * sin(hd);
  ld bx = ld(B) * cos(md);
  ld by = ld(B) * sin(md);
  ld dx = ax - bx;
  ld dy = ay - by;
  ld len = sqrtl(dx * dx + dy * dy);
  cout << std::setprecision(16) << len;
  return 0;
}
