#include <bits/stdc++.h>
using namespace std;
void Fast_IO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
vector<vector<long long> > vii;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double x = (h * 60 + m) / 2;
  double y = 6 * m;
  double angle = abs(x - y);
  angle = min(360 - angle, angle);
  double k = 3.14159265359 / 180.0;
  if (angle == 180) {
    double ans = a + b;
    cout << fixed << setprecision(18) << ans;
  } else if (angle == 0) {
    double ans = 0;
    cout << fixed << setprecision(18) << ans;
  } else {
    angle = angle * k;
    double p = cos(angle);
    if (p < -1) p = 0;
    double ans = 0.000000000000000001;
    ans += pow(a, 2) + pow(b, 2) - 2 * a * b * p;
    ans = sqrt(ans);
    cout << fixed << setprecision(18) << ans;
  }
}
