imput = gets.chomp.split(" ").map!{|item| item.to_i}
a = imput[0]
b = imput[1]
h = imput[2]
m = imput[3]

hang = (30*h + m/2)
mang = m*6

hy = 0.to_f
hy = 0.to_f
my = 0.to_f
mx = 0.to_f
hy = Math.sin(Math::PI*hang/180)*a
hx = Math.cos(Math::PI*hang/180)*a
my = Math.sin(Math::PI*mang/180)*b
mx = Math.cos(Math::PI*mang/180)*b
puts Math.sqrt((hy-my)**2 + (hx-mx)**2)
