#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double am = m * 6;
  double ah = 30 * h + 0.5 * m;
  double d = abs(am - ah);
  if (d > 180) {
    d = 360 - d;
  }
  double ans = sqrt(a * a + b * b + -2 * a * b * cos(d));
  cout << setprecision(21) << ans;
  return 0;
}
