const hours = 12
const minutes = 60

const processData = (lines) => {
  const [a, b, h, m] = lines[0].split(' ').map(x => +x)


  const angleDiff = Math.min(Math.abs(h/hours - m/minutes), 1 - Math.abs(m/minutes - h/hours))

  console.log(Math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * Math.cos(angleDiff * 2 * Math.PI))).toFixed(10))
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})
