'use strict'

const Main = (input) => {
  const [A, B, H, M] = input.trim().split(' ').map(Number)

  const thetaH = ((H + M / 60) / 12) * Math.PI * 2
  const thetaM = (M / 60) * Math.PI * 2

  const theta = thetaH - thetaM

  let result = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(theta)))

  console.log(result)
  return result
}


Main(require('fs').readFileSync('/dev/stdin', 'utf8'))