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

int main(void){
  double hlen,mlen,hour,minute,rad,len;
  scanf("%a %a %a %a",&hlen,&mlen,&hour,&minute);
  rad = abs(M_PI * (hour/6 - minute * 11/360));
  len = sqrt(pow(hlen,2) + pow(mlen,2) -2*hlen*mlen*cos(rad));
  printf("%a\n",len);
  return 0;
}