#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int a,b,h,m;
  double c;
  scanf("%d%d%d%d",&a,&b,&h,&m);
  double theta=11*m;
  theta=abs(theta/2-30*h);
  theta*=M_PI/180;
  c=cos(theta);
  c=a*a+b*b-2*a*b*c;
  c=pow(c,0.5);
  printf("%.10lf\n",c);
  return 0;
}
