#include <stdio.h> 
#include <math.h>
#define npi 0.314159265358979323846
int main() {
  int a,b,h,m;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);
  double theta = (h*120-23*m)*npi/72;
  double L;
  if (theta<=10*npi) L = sqrt(a*a+b*b-2*a*b*cos(theta));
  else L = sqrt(a*a+b*b+2*a*b*cos(theta));
  printf("%.10lf\n",L);
  return 0;
}