#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.14159265
 
int main(void){
  int A,B,H,M;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  double Aangle,Bangle,angledif,length;
  Bangle = M/60.0*360.0;
  Aangle = H/12.0*360.0 + M/60.0*30.0;
  angledif = fabs(Aangle - Bangle);
  double rad = angledif * PI / 180.0;
  length = sqrt(pow((double)A,2.0)+pow((double)B,2.0)-2.0*(double)A*(double)B*cos(rad));
  printf("%f",length);
  return 0;
}