//░░░
// ░ anzim bin nasir
// ░
#include <stdio.h>
#include <math.h>
 
int main()
{
  double hlen,mlen,hour,minute,rad,len;
  scanf("%lf %lf %lf %lf",&hlen,&mlen,&hour,&minute);
  rad = M_PI * (hour/6 - minute * 11/360);
  len = sqrt(pow(hlen,2) + pow(mlen,2) -2*hlen*mlen*cos(rad));
  printf("%.10f\n",len);
  return 0;
}
