#include<stdio.h>
#include<math.h>

int main()
{
    int A,B,H,M;
    scanf("%d%d%d%d",&A,&B,&H,&M);

    double kakuA,kakuB;
    kakuA=(double)0.5*(60*H+M);
    kakuB=(double)6*M;
  	
  	double sa,ans;
  	sa=fabs(kakuA-kakuB)*M_PI/180;
  	ans=sqrt(A*A+B*B-2*A*B*cos(sa));
  	printf("%.16lf",ans);
  	

    return 0;
}
