#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int a,b,h,m;
  double c;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  int abrad = abs(m*6-h*30);
  if(abrad > 180) abrad -=180;
  c = sqrt(a*a+b*b-(2*a*b)*cos(abrad));
  printf("%lf",c);
}