#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double a, b;
  double h, m;
  cin >> a >> b >> h >> m;
  double ang_h = h / 12.0;
  double ang_m = m / 60.0;
  double ang = min(ang_h - ang_m, 2 * 3.14159265358979 - ang_h + ang_m) *
               3.14159265358979 * 2;
  double ans = pow(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(ang), 0.5);
  cout << ans << endl;
  return 0;
}
