#include <stdio.h>
#include <math.h>
int main(){
  int A,B,H,M;
  scanf("%d %d %d %d",&A,&B,&H,&M);
  double L;
  L=sqrt(pow(A*cos(M_PI/6*H+M_PI/360*M)-B*cos(M_PI/30*M),2)+pow(A*sin(M_PI/6*H+M_PI/360*M)-B*sin(M_PI/30*M),2));
  printf("%lf\n",L);
  return 0;
}