const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
const [A, B, H, M] = input[0].split(' ').map(Number)

const degA = (H * 30) + (M / 60 * 30)
const degB = M * 6

const deg = Math.abs(degA - degB) % 180
const rad = deg * ( Math.PI / 180 )

const height = A * Math.sin(rad)
const width  = A * Math.cos(rad) - B

const ans = Math.sqrt(Math.pow(height, 2) + Math.pow(width, 2))
console.log(ans)
