import sys
import numpy as np

i = list(map(int, input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]
time = h*60+m
ths = np.pi/2-(np.pi * time/(60*12))
thl = np.pi/2-(np.pi * m/30.0)
#ths = np.deg2rad(90-h*30.0)
#thl = np.deg2rad(90-m*6.0)
x1 = a*np.cos(ths)
y1 = a*np.sin(ths)
x2 = b*np.cos(thl)
y2 = b*np.sin(thl)
print(np.sqrt((x1-x2)**2+(y1-y2)**2))
