#include <bits/stdc++.h>
using namespace std;
int main() {
  float a, b, h, m, x;
  scanf("%f%f%f%f", &a, &b, &h, &m);
  float y = m / 2;
  if (h * 5 >= m) {
    x = ((h * 5) - m) * 6 + y;
  } else {
    x = (m - (h * 5)) * 6 + y;
  }
  float ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(x * M_PI / 180.0)));
  cout << setprecision(20) << fixed;
  cout << ans;
}
