#include<stdio.h>
#include<math>
int main(){
int A,B,H,M,Angle,result=0;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  Angle=0.5(60*H-11*M);
    if (Angle<0)
      Angle=Angle*-1;
  result=sqrt(A*A + B*B - 2*A*B*cos(Angle));
  printf("%d",result);
  return 0;
}