process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var abhm = lines[0].split(' ');
 var a = Number(abhm[0]);
 var b = Number(abhm[1]);
 var h = Number(abhm[2]);
 var m = Number(abhm[3]);

 var hkaku = h * 30 + m * 0.5;
 var mkaku = m * 6;
 var kaku = Math.abs(hkaku-mkaku);
 var kaku2 = 360 - Math.abs(hkaku-mkaku);
 kaku = Math.min(kaku2,kaku);
 kaku = Math.cos(kaku*(Math.PI/180));

 var ans = (a*a) + (b*b) - (2*a*b*kaku);
 console.log(Math.sqrt(ans));
});
