#include<stdio.h>
#include<string.h>
#include<math.h>
#define zettaisa(x,y) x<y?y-x:x-y
#define m(x,v) x<v?x:v
#define pi 3.1415926535
int main(){
  int A,B,H,M;
  double ans,sita;
  scanf("%d%d%d%d",&A,&B,&H,&M);
  (double)A;(double)B;(double)H;(double)M;
  H=H*60+M;
  sita=zettaisa(H*pi/360,M*pi/30);
  ans=sqrt(A*A+B*B-cosl(sita)*A*B*2);
  printf("%f",ans);
};