#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double ans;
  double totaldegree;
  if (m == 0) {
    totaldegree = (double)h * 30;
    if (h == 12) totaldegree = 0;
  } else {
    totaldegree = (double)abs((h * 30) - (double)((m / 5) * 30));
    totaldegree += (double)(m / 2);
  }
  if (totaldegree > 180) totaldegree = (double)(360 - totaldegree);
  totaldegree = (double)3.14159265358979323846 * totaldegree / 180;
  ans = (double)sqrt((((a * a) + (b * b)) - (2 * a * b * cos(totaldegree))));
  cout << setprecision(20) << ans << "\n";
  return 0;
}
