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

int main(void){
  int A,B,H,M;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  
  double the = 30 * H - 6 * M;
  
  if(-180.0 <= the && the <= 180){
    printf("%lf",sqrt((double)A^2.0 + (double)B^2.0 - 2 * A * B * cos(the)));
  }else{
    printf("%lf",sqrt((double)A^2.0 + (double)B^2.0 - 2 * A * B * cos(fabs(the))));
  }
  return 0;
}
