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

double min(double a,double b){
    if(a>b) return a;
    else return b;
}
int main(){
  double rad = 0.01745329252;
  int a,b,h,m;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);
  double angle = (h*30)+(m/2)-(m*6);
  angle = min(angle,360-angle);
  angle = angle*rad;
  double ca = cos(angle);
  double temp = 2*a*b*ca;
  double ans = sqrt((a*a)+(b*b)-temp);
  printf("%0.9f\n",ans);
  return 0;
}
