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

int main(void)
{
  int a,b,h,m;
  double lhand,shand,x,y,ans;

  scanf("%d %d %d %d",&a,&b,&h,&m);

  lhand = m*M_PI/30;
  shand = (60*h+m)*M_PI/360;

  x = a*sin(lhand)-b*sin(shand);
  y = a*cos(lhand)-b*cos(shand);
  
  ans = sqrt(x*x+y*y);

  printf("%.20lf\n",answer);

  return 0;
}