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

int main(void)
{
  int a,b,h,m;
  double lhand,shand,theta,answer;

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

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

  if(lhand>shand) theta=lhand-shand;
  else theta=shand-lhand;

  if(theta>M_PI) theta-=M_PI;

  answer = sqrt(a*a+b*b-2*a*b*cos(theta));

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

  return 0;
}