function main(input) {
  var inputs = input.trim().split('\n');
  inputs = inputs[0].split(' ');
  var A = inputs[0] - 0;
  var B = inputs[1] - 0;
  var H = inputs[2] - 0;
  var M = inputs[3] - 0;

  var minutes = 60 * H + M;
  var radA = minutes / 60 * 30;
  var radB = M * 6;
  radB = radB == 0 ? 360 : radB;

  if (radA == radB) {
    console.log(Math.max(A, B));
  } else if (radA > radB) {
    var rad = (radA - radB) * Math.PI / 180;
    var pA = [A, 0];
    var pB = [B * Math.cos(rad), B * Math.sin(rad)];
    console.log(Math.sqrt(Math.pow(pB[0] - pA[0], 2) + Math.pow(pB[1] - pA[1], 2)));
  } else {
    var rad = (radB - radA) * Math.PI / 180;
    var pB = [B, 0];
    var pA = [A * Math.cos(rad), A * Math.sin(rad)];
    console.log(Math.sqrt(Math.pow(pB[0] - pA[0], 2) + Math.pow(pB[1] - pA[1], 2)));
  }
}

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