#include<stdio.h>
#include<math.h>
int main(void){
 double a,b,n,m;
  scanf("%lf%lf%lf%lf",&a,&b,&n,&m);
  n=30.0*n;m=m*6.0;
  printf("%.10f",sqrt(a*a+b*b-2*a*b*cos((n-m)/360.0*2.0*M_PI)));
  return 0;}