#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(17);
  double a, b, c, d;
  if (d == 0) d = 60;
  if (c == 0) c = 60;
  cin >> a >> b >> c >> d;
  double angle = (3.14159265358979323 * 6 * abs(5 * c - d)) / 180;
  double ans = sqrt(a * a + b * b + 2 * a * b * cos(angle));
  cout << ans;
  return 0;
}
