#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
#define pai 3.14159265359f;
int main(void)
{
  double a,b,h,m,p=pai;
  double r,ans;
  
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  
  r=m*6-(h*30+(m/2));
  r=r/180*p;
  ans=sqrt(a*a*sin(r)*sin(r)+(b-a*cos(r))*(b-a*cos(r)));
  
  printf("%f",ans);
}