#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double h, m, a, b;
  cin >> a >> b >> h >> m;
  double hour_angle = 0.5 * (h * 60 + m);
  double minute_angle = 6 * m;
  double angle = abs(hour_angle - minute_angle);
  angle = min(360 - angle, angle);
  double c = sqrt(b * b + a * a - 2 * a * b * cos(angle * acos(-1) / 180));
  cout << setprecision(20) << fixed << c << endl;
  return 0;
}
