import sys
from math import cos, radians, pi, sqrt
 
 
input = input().split()
 
A = int(input[0])
B = int(input[1])
H = int(input[2])
M = int(input[3])
 
rad = 2*pi*(H/12.0+(M/60.0)/12.0-M/60.0)
out = sqrt((pow(A,2)+pow(B,2))-(2*A*B*cos(rad)))
 
print(out)