#include<bits/stdc++.h>
#define pi 3.14159265358979323846
using namespace std;
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=abs(pi/30*(60*h+m)*(1/12.0-1));
	
	double c=sqrt(pow(a*cos(ang)-b,2)+pow(a*sin(ang),2));
	cout<<setprecision(25)<<c<<endl;
	
}