#include <bits/stdc++.h>
int main() {
  int A, B, H, M;
  std::cin >> A >> B >> H >> M;
  printf("%4.10f", sqrt(A * A + B * B -
                        2 * A * B * cos((H * 30 - M * 5.5) * M_PI / 180)));
}
