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


int main(void){

int a,b,h,m;
scanf("%d%d%d%d",&a,&b,&h,&m);

long double xa,ya,xb,yb;

xa = a*sin(1.00*h/1.0/12*2*M_PI+1.00*m/1.0/60*2*M_PI/12);
ya = a*cos(1.00*h/1.0/12*2*M_PI+1.00*m/1.0/60*2*M_PI/12);

xb = b*sin(1.00*m/60*2*M_PI);
yb = b*cos(1.00*m/60*2*M_PI);

//printf("%lf\n%lf\n%lf\n%lf\n",xa,ya,xb,yb);

long double x_distance,y_distance;

x_distance = xa-xb;
y_distance = ya-yb;

long double distance_pow;
distance_pow = 1.0*x_distance*x_distance+1.0*y_distance*y_distance;

long double distance;
distance =  sqrtl(distance_pow);

printf("%10.10Lf\n",distance);
return 0;
}