from sys import stdin
import math
b, c, tanshin, choshin = [int(x) for x in stdin.readline().rstrip().split()]
 


choshin12 = choshin * (360 / 60)
if choshin == 0 :
	choshin12 = 360/60
 
tanshin12 = (tanshin * 60 + choshin) * 360 / (12 * 60)
 
rad =  abs( choshin12 - tanshin12 )
 
# 線対称で書いちゃったよ。。。点対称じゃんね
if rad >= 180 :
	rad = 360-rad
 
# 余弦定理とか生まれて初めてです・・・
a = (b ** 2) + (c ** 2) - (2 * b * c * math.cos(math.radians(rad)))
 
# print (math.cos(math.radians(rad)))
 
a = math.sqrt(a)

# print(tanshin)
# print(choshin)
 
# print(tanshin12)
# print(choshin12)
 
# print(rad)
print (a)