import math

A, B, H, M = map(int, input().split())

cho = (H * 60 + M) / (12 * 60) * 360
tan = M / 60 * 360
degree = abs(cho-tan)

ans_2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(degree))
print(math.sqrt(ans_2))
