#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double ang = 0;
  long double ang_hr = 0;
  long double ang_min = 0;
  ang_hr = (long double)30 * (h + ((long double)m / 60));
  ang_min = (long double)6 * m;
  ang = (long double)abs(ang_hr - ang_min);
  if (ang > (long double)180) ang = (long double)(ang - (long double)180);
  long double ans = 0;
  ans = (long double)(a * a + b * b);
  ans = (long double)ans -
        (long double)(2 * a * b *
                      cosl((long double)(ang *
                                         3.14159265358979323846264338327950L) /
                           (long double)180));
  cout << fixed << setprecision(20) << sqrtl(ans) << endl;
  return 0;
}
