import numpy as np

a, b, h, m = map(int, input().split())

H = h * 30 + m*0.5
M = m * 6

if(H > M):
    deg = H - M
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
elif(H < M):
    deg = M - H
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
else:
    print(b-a)
