#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-h*5)*6;
  if(abrad > 180) abrad -=180;
  if(abrad > 90) abrad -= 90;
  c = sqrt(a*a+b*b-2*a*b*cos(abrad));
  printf("%lf",c);
}