#include<bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384
int main()
{
	double a,b,h,m,s,ans;
	cin>>a>>b>>h>>m;
	s=fabs((PI/6*h+PI/360*m)-(PI/30*m));
	ans=a*a+b*b-2*a*b*cos(s);
	ans=sqrt(ans);
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}