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

int main(){
  int A,B,H,M,time;
  double kaku,len;
  scanf("%d%d%d%d",&a,&b,&h,&m);
  
  time=60*h+m;
  kaku=time*5.5;
  
  len=sqrt(a^2+b^2-2*a*b*cos(kaku));
  
  printf("%.10lf",len);
  
}