#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define BUFSIZE 10000000
typedef long long ll;
#define WDSIZE 10000

float A,B,H,M;
char a[BUFSIZE]={0};
double C_dub,answer;
int cal(float a,float b,double s_cos){
  C_dub = a*a+b*b - 2*a*b*cos(s_cos);
  answer = sqrt((double)C_dub);
  return 0;
}


int main(void){
  scanf("%f",&A);
  scanf("%f",&B);
  scanf("%f",&H);
  scanf("%f",&M);



  double L_S = H*30 + M/2 - 6*M;
  L_S = abs(L_S);
  if(L_S > 180) L_S = 360 - L_S;
  double p = L_S/180 * M_PI;
  cal(A,B,p);
  printf("%0.15f",answer);

}
