#include <bits/stdc++.h>
using namespace std;
long long const M = 1000000007;
double const pi = acos(-1);
long long const inf = 2e18;
long long const N = 200001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double i, j, t, a, b, h, m;
  cin >> a >> b >> h >> m;
  double angle = 6 * (max(5 * h, m) - min(5 * h, m));
  if (angle > 180) angle = 360 - angle;
  angle *= (pi / 180);
  cout << setprecision(15) << fixed
       << sqrt(a * a + b * b - 2 * a * b * cos(angle)) << "\n";
  return 0;
}
