#include <bits/stdc++.h>
using namespace std;
long double my_sqrt(long double a) {
  long double x = 1.0;
  long double eps = 0.000000000001;
  while (abs(a - x * x) > eps) {
    x = (x + a / x) / 2;
  }
  return x;
}
int main(void) {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  int time_min;
  time_min = 60 * h + m;
  long double pi = 3.141592653589793238;
  long double w_t = 0.5;
  long double w_m = 6.0;
  long double kaku;
  kaku = w_t * time_min - w_m * m;
  kaku = kaku * pi / 180.0;
  long double c = cos(kaku);
  long double x;
  x = a * a + b * b - 2 * a * b * c;
  x = my_sqrt(x);
  cout << fixed << setprecision(15) << x << endl;
  return 0;
}
