'use strict'

function main(input) {
    const n = input.trim().split(/\s/).map(str=>~~str)
    
    const deg = Math.abs( (360*n[2] / 12) + 30*n[3] / 60 - (360*n[3] / 60)) % 360
    
    console.log(Math.sqrt(n[0]**2 + n[1]**2 - 2*n[0]*n[1]*Math.cos(deg * Math.PI / 180)))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
