#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double c, c2, x, r1, r2, pi;
  pi = 3.1415926535897932384;
  r1 = 2 * pi * (h * 60 + m) / 720;
  r2 = 2 * pi * m / 60;
  if (r2 < r1) {
    x = r1 - r2;
  } else {
    x = r2 - r1;
  }
  c2 = a * a + b * b - 2 * a * b * cos(x);
  c = sqrt(c2);
  cout << c << endl;
  return 0;
}
