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

int main(){
  double a,b,h,m,x,y;
  scanf("%lf",&a);
  scanf("%lf",&b);
  scanf("%lf",&h);
  scanf("%lf",&m);
  h=(h*60+m)*M_PI/360;
  m*=M_PI/30;
  y=a*cos(h)-b*cos(m);
  x=a*sin(h)-b*sin(m);
  printf("%.10lf",sqrt(pow(x,2)+pow(y,2)));
  return(0);
}