#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 len,len_2;
  double rad = get_rad(h,m);
  //printf("%lf",rad);
  len_2 = pow(a-b*cos(rad),2)+pow(b*sin(rad),2);
  len =sqrt((double)len_2);
  printf("%10f",len);
  return 0;
}
