#define _USE_MATH_DEFINES
#include <stdio.h>
#include<string.h>
#include <stdlib.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592


int main(){
  int A,B, H, M;
  scanf("%d%d%d%d", &A, &B, &H, &M);
  int  sumtime = H*60+M;
  double  sumangle = fabs(6* M - (30 * H + 0.5*M));
    if(sumangle >= 180){
      sumangle = sumangle -180;
    } 
    double sumrad = (M_PI *sumangle)/180;
    double sumcos = cos((M_PI *sumangle)/180);
  double x = pow (A, 2.0);
  double y = pow (B, 2.0);
  //double z = 2*A*B* cos(M_PI *sumangle)/180);
  double ans = sqrt(x+y-2*A*B*sumcos);
  //printf("%d\n",sumtime);
  //printf("%f\n",sumangle);
  //printf("%lf\n",ans);
 // printf("%lf\n",x);
  //printf("%lf\n",y);
  printf("%.20f\n",ans);
  //printf("%lf\n",sumrad);
  //printf("%lf\n",z);

  
return 0;
}