#include <bits/stdc++.h>
int A, B, H, M;
long double gannma, c, zeta;
const long double PI = 3.14159265358979323846;
int main() {
  std::cin >> A >> B >> H >> M;
  zeta = std::abs(((long double)(H + ((long double)M) / 60)) / 12 -
                  ((long double)M) / 60);
  gannma = 2 * PI * (zeta > 0.5 ? zeta - 0.5 : zeta);
  c = std::sqrt(std::abs(A * A + B * B - 2 * A * B * std::cos(gannma)));
  std::cout << std::fixed << std::setprecision(20) << c << std::endl;
}
