#include <stdio.h>
#include <math.h>
int main(){
  int A,B,H,M;
  double ans,a,b,x;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  a=30*H+0.5*M;
  b=6*M;
  if(a>b) x=a-b;
  else x=b-a;
  ans=sqrt(A*A+B*B-2*A*B*cos(x/180*M_PI));
  printf("%.15f",ans);
  return 0;
}