/// ****** Property of vipulks ****** \

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

#define ll long long
#define PI 3.1415926535
int main(){
	ll t,n,i,j,a,b,c,d,h,m;
	double k,k1,k2,ans;
	t=1;//scanf("%lld",&t);
	while(t--){
		scanf("%lld%lld%lld%lld",&a,&b,&h,&m);
		i=m/60;
		j=m%60;
		h+=i;
		m=j;
		k=PI*h/6;
		k1=PI*m/30;
		if(k>k1)
			k2=k-k1;
		else
			k2=k1-k;
		ans=a*a+b*b-2*a*b*cos(k2);
		printf("%lf\n",sqrt(ans));
	}
	return 0;
}