#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define PI 3.14159265358979323846264338327950L
 
int main(){
 
  int a,b;
  int h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);
 
  long double angle =  30*h + 0.5*(long double)m - (double)m * 6 ;
  long double rad;
    //rad = (angle /180)* M_PI;
 
  //printf("%.10f ",h);
  long double ans = (long double)a*a + (long double)b*b - (long double)(2*a*b)*cosl(angle * (PI / 180));
  printf("%20.20Lf\n",sqrtl(ans));
 
  return 0;
}