import math
 
A,B,H,M=map(int,input().split(" "))
 
hour=[A*math.cos(math.radians(H*30+M/2)),A*math.sin(math.radians(H*30+M/2))]
minute =[B*math.cos(math.radians(M*6)),B*math.sin(math.radians(M*6))]
if (hour[0]>=0 and minute[0]>=0) or (hour[0]<0 and minute[0]<0):
    a=minute[0]-hour[0]
else:
    a=abs(minute[0])+abs(hour[0])
    
if (hour[1]>=0 and minute[1]>=0) or (hour[1]<0 and minute[1]<0):
    b=minute[1]-hour[1]
else:
    b=abs(minute[1])+abs(hour[1])    
print('{:.16f}'.format(math.sqrt(pow(a,2)+pow(b,2))))