import math

if __name__ =='__main__':
    a, b, h, m = map(int, input().split())
    h = h * 30 + m/2
    m = m * 6
    degree = abs(h - m)
 
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree))))