inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
inp = inp.shift().split(" ").map((x) => +x)
A = inp.shift()
B = inp.shift()
H = inp.shift() 
M = inp.shift()

p = 10e10

h = H / 12 * 360 + M / 60 * 360 / 12
h = h * (Math.PI / 180)  
m = M / 60 * 360
m = m * (Math.PI / 180)  

t = function(n) {
    return Math.round(n * p) / p
}

ax = A * t(Math.cos(h))
ay = A * t(Math.sin(h))
bx = B * t(Math.cos(m))
by = B * t(Math.sin(m))

c = Math.sqrt((ax - bx)*(ax - bx) + (ay - by)*(ay - by))

console.log(c)
