import math

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

tan=h*30+0.5*m
cho=6*m

kakudo=float(100)

if math.sqrt((tan-cho)*(tan-cho))>180:
	kakudo=360-math.sqrt((tan-cho)*(tan-cho))
	print(math.sqrt(a*a+b*b-2*a*b*(math.cos(math.radians(kakudo)))))

if math.sqrt((tan-cho)*(tan-cho))==180:
	print(a+b)

if math.sqrt((tan-cho)*(tan-cho))<180:
	kakudo=math.sqrt((tan-cho)*(tan-cho))
	print(math.sqrt(a*a+b*b-2*a*b*(math.cos(math.radians(kakudo)))))