#include <bits/stdc++.h>
using namespace std;
int main() {
  const double pi = acos(-1);
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double x;
  x = sqrt(a * a + b * b - 2 * cos(abs((h * 6 * pi - m * pi) / 30)));
  cout << x << endl;
}
