import math

INF = 10 ** 9
A,B,H,M = map(int,input().split())

rad_H = (360*H/12) + (0.5 * M)
rad_M = 360*M/60
diff = abs(rad_H-rad_M)

if diff > 180:
	diff = diff - 180

temp = (A ** 2) + (B ** 2) -(2*A*B*math.cos(math.radians(diff))) 
ans = math.sqrt(temp)

print(ans)
