#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double time=h*60+m;
	double ang=time*(5.5);
	double ans=a*a+b*b-2*a*b*cos(ang/180*3.1415926535897932);
	printf("%.9f",sqrt(ans));
	return 0; 
}