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

double get_rad(int a,int b){
  double rad_a ,rad_b;
  int min = a*60+b;
  rad_b = 2*M_PI*(b%60)/60;
  rad_a = 2*M_PI*(min%720)/720;
  return fabs(rad_a-rad_b);
}

int main(void){
  int a,b,h,m;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  double dx,dy,len;
  double rad = get_rad(h,m);
  //printf("%lf",rad);
  dx = (double)a-(double)b*cos(rad);
  dy = 0-(double)b*sin(rad);
  len =sqrt(pow(dx,2)+pow(dy,2));
  printf("%.12f",len);
  return 0;
}
