#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
const long long INF = long long(1e18) + 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double pi = 3.141592;
  long double funkaku, jikaku;
  funkaku = M * 2 * pi / 60;
  jikaku = H * 2 * pi / 12 + M * 2 * pi / 720;
  long double theta = abs(funkaku - jikaku);
  long double result;
  if (theta == 0) {
    result = abs(A - B);
  } else {
    result = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cosl(theta));
  }
  cout << result;
}
