#include "bits/stdc++.h"
using namespace std;

int a,b,h,m;

int main()
{
	cout<<fixed<<setprecision(12);
	cin>>a>>b>>h>>m;

	double ha=h*30+m/2.,ma=6*m,ang=abs(ha-ma);
	ang=min(ang,360-ang);
	cout<<sqrtl(a*a+b*b-2*a*b*cos(ang*M_PI/180));
}