#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double pi = 3.14159265358979323846264338;
int main() {
  long double a, b, h, m, x;
  cin >> a >> b >> h >> m;
  double c = 11.0 / 360.0 * (60 * h + m) * pi;
  x = pow((a * a + b * b - 2 * a * b * cos(c)), 0.5);
  cout << fixed << setprecision(20) << x << endl;
  return 0;
}
