#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950L
int main(void){
  int a, b, h, m;
  scanf("%d%d%d%d", &a, &b, &h, &m);
  long double rad=2*PI*((long double)h/12.0-11.0*(long double)m/720.0);
  long double rsq=(long double)(a*a+b*b)-(long double)(2*a*b)*cosl(rad);
  printf("lf",sqrtl(rsq));
  return 0;
}
  
