#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline bool CMAX(T &m, U x) {
  if (m < x) {
    m = x;
    return true;
  }
  return false;
}
template <typename T, typename U>
inline bool CMIN(T &m, U x) {
  if (m > x) {
    m = x;
    return true;
  }
  return false;
}
const int INF = 1e9;
const long long LINF = 1e18;
const long double pi = acosl(-1);
int main() {
  int h, m;
  long double a, b;
  cin >> a >> b >> h >> m;
  long double tansin =
      2 * pi * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0);
  long double tyosin = 6.0 * m;
  long double kakudo = tansin - tyosin;
  long double c =
      powl(a, 2) + powl(b, 2) - 2.0 * a * b * cosl(kakudo * (pi / 180.0));
  cout << std::fixed << std::setprecision(20) << powl(c, 0.5) << endl;
  return 0;
}
