fs = require('fs');
input = fs.readFileSync('/dev/stdin','utf-8');
tmp = input.split(' ');
A = parseInt(tmp[0],10);
B = parseInt(tmp[1],10);
H = parseInt(tmp[2],10);
M = parseInt(tmp[3],10);
HX = A * Math.sin(2 * Math.PI * (H % 12) / 12);
if((H % 12)== 6  || (H % 12) == 12) HX = 0;
HY = A * Math.cos(2 * Math.PI * (H % 12) / 12);
if((H % 12)== 3  || (H % 12) ==  9) HY = 0;
MX = B * Math.sin(2 * Math.PI * (M % 60) / 60);
if((M % 60)== 30 || (M % 60) == 60) MX = 0;
MY = B * Math.cos(2 * Math.PI * (M % 60) / 60);
if((M % 60)== 15 || (M % 60) == 45) MY = 0;
console.log(Math.sqrt((HX - MX) * (HX - MX) + (HY - MY) * (HY - MY)));
