#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int a,b,h,m;
double x,y,ang;
int main()
{
	scanf("%d%d%d%d",&a,&b,&h,&m);
	x=(h+m/60.0)*pi/6;
	y=m*pi/30;
	ang=min(fabs(x-y),2*pi-fabs(x-y));
	printf("%.20lf\n",sqrt(a*a+b*b-2*a*b*cos(ang)));
	return 0;
}
