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

#define abs(a,b) (a-b < 0 ? b-a:a-b)
#define PI 3.14159265359

int main()
{
  int a,b,h,m;
  
  double Hang=0,Mang=0;
  
  scanf("%d %d %d %d",&a,&b,&h,&m);

  Hang=(h*60+m)*0.5;
  Mang=m*6;
  
  double ang;
  ang=abs(Hang,Mang);
  if(ang>180)
    ang-=180;
  ang=ang*PI/180.0;
  ang=cos(ang);
  
  double ans=a*a+b*b;
  
  ans-=2*a*b*ang;
  
  ans=sqrt(ans);
  
  printf("%.10lf",ans);
}