#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,h,m,h1,m1;
	cin>>a>>b>>h>>m;
	m1=m*360/60;
	h1=h*360/12+0.5*m;
	cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(abs(m1-h1)/360*2*3.1415926535));
	return 0;
}