#include<stdio.h>
#include <stdlib.h>
#include<math.h>
#define PI 3.141592653589793238
int main(){
   int A,B,H,M;
   scanf("%d %d %d %d",&A,&B,&H,&M);
   long double ans;

   ans = cos(2*PI*(H/12.0 + (M/(60.0*12.0)) - M/60.0));
   printf("%Lf\n",sqrt(A*A+B*B-2*A*B*ans));
   return 0;
}
