#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define pi 3.14159265358979323846

int main(void){
  int A,B,H,M;
  scanf("%d%d%d%d",&A,&B,&H,&M);
  double degH=(2*pi*(60*(double)H+(double)M))/720,degM=2*pi*(double)M/60;
  
  double C = sqrt((double)(A*A)+(double)(B*B)-(2*(double)A*(double)B*cos((double)degH-degM)));
  
  printf("%.20f",C);
  return 0;
}