'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(x=> x*1);
  let A = inp[0];
  let B = inp[1];
  let H = inp[2];
  let M = inp[3];
  let Hkaku = H*30 + M*0.5;
  let Mkaku = M*6;
  let kaku = (Mkaku - Hkaku)* Math.PI /180;
  let ans = 0;
  
  // 余弦定理に打ち込む
  ans = Math.sqrt(A*A + B*B - 2 * A * B * Math.cos(kaku));

  
  console.log(ans);

}

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