import math as ma

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

al = h*30
bl = m*6
dec = al-bl
dec = dec % 180
if dec < 0:
  dec *= -1
rad = dec * ma.pi / 180
r = ma.sqrt(a**2 + b**2 -2*a*b*ma.cos(rad))
print(r)