'use strict';
const p = s => console.log(s);
// let a,b,c,d;
// [a,b,c,d] = input[0].trim().split(" ").map(i => parseInt(i));

function main(input) {

  let a,b,h,m;
  [a,b,h,m] = input[0].trim().split(" ").map(i => parseInt(i));

  let ans = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(2*Math.PI*(h/12 + (m/60)/12 - (m/60))));

  p(ans);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));
