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

double A,B,H,M;
char a[BUFSIZE]={0};
double C_dub,answer;


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




double L_S = abs(H*30 + M/2 - 6*M);

  printf("%0.15f", sqrt(A*A+B*B - 2*A*B*cos(L_S/180 * M_PI)));

}
