#include <bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long> > que;
priority_queue<long long> Que;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int a, b, h, m;
static const double pi = 3.141592653589793;
void solve() {
  cin >> a >> b >> h >> m;
  double ans = 0;
  double theta;
  double sh = (h * (360 / 12)) + m * 0.5;
  double lg = m * (360 / 60);
  theta = abs(lg - sh);
  theta = min(theta, (360 - theta));
  theta = (theta) * (pi / 180);
  ans = a * a + b * b - 2 * a * b * cos(theta);
  ans = sqrt(ans);
  printf("%.10f\n", ans);
}
int main() {
  solve();
  return 0;
}
