#include<stdio.h>
#include<math.h>
#define Pi 3.1415926535897932384626433
int main(){
int H,M,A,B,J;
double t,n,b,ans,cout;
 scanf("%d %d %d %d",&A,&B,&H,&M);
t=M/2.0;
n=30*H+t;
J=6*M;
ans=fabs(n-J);
if(ans>=180) ans=360-ans;
b=(ans*Pi)/180;
cout=sqrt(A*A+B*B-2*A*B*cos(b));
printf("%.20lf",cout);
return 0;
}