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

int main(){
  int a,b,h,m;
  double theta,c;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  
  theta=2*M_PI*((double)h/12.0 + ((double)m/60.0)/12.0 - (double)m/60.0);
  
  
  c=(double)(a*a + b*b)-(double)(2*a*b)*cos(theta);
  printf("%.15f\n",sqrt(c));
  
  return 0;
}
  
  