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

int main(){
  int a,b,h,m;
  double pai,ans2,ans;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  pai=(fabs(30*h+0.5*m - 6*m)/180)*3.14159265358979;
  ans2=a*a+b*b-2*a*b*cos(pai);
  ans=sqrt(ans2);
  printf("%.12f",ans);
}