#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define pi acos(-1)

int A,B,H,M;
double k,C;
int main(){
  scanf("%d %d %d %d",&A,&B,&H,&M);
  H=30*H+30*M/60;
  M=6*M;
  k=fabs(H-M);  //kは角度
  C=A*A+B*B-2*A*B*(cos(t*pi/180));
  C=sqrt(C);
  printf("%.20lf\n",C);
  return(0);
}
