#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(){
  int a,b,h,w,m; //0<=w<=11  0<=m<=59 0<=a,b<=1000
  double rad;//角度
  double tmp;
  double rength; // a^2
  double ans;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  rad = 2*PI*((h/12.0+m/(12.0*60.0))-(m/60.0)); //2*PI:円一周の角度(360℃)　短針の角度：360(H/12+M/(12*60))長針：m/60
if(rad<0){
  tmp=rad*(-1);
  rad = tmp;
}
if(rad>=180){
  tmp = 360 - rad;
  rad = tmp;
}
//printf("rad = %f\n",rad);
rength = a*a+b*b-2*a*b*cos(rad);
//printf("rength = %f\n",rength);
ans = sqrt(rength);
printf("%.20f\n",ans);

  return 0;
}
