#include <bits/stdc++.h>
using namespace std;
void solve() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  cout << setprecision(20)
       << sqrt(a * a + b * b -
               2 * a * b *
                   cos((0.5 * (m + 60 * h) - 6 * m) *
                       (3.141592653589793238462643383279 / 180)));
}
int main() {
  solve();
  return 0;
}
