#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double hjd,mjd,jd,s;
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	hjd=(h*60+m)*0.5;
	mjd=m*6;
	jd=fabs(hjd-mjd);
	if(jd>180)
		jd=360-jd;
	printf("%.20f",sqrt(a*a+b*b-2*cos(jd*M_PI/180)*a*b));
	return 0;
}