#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
void solve() {
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double hd,md;
	double pi=4*atan(1.0);
	hd=(double)((h*60+m)%720)/720*2*pi;
	md=(double)m/60*2*pi;
	double ddeg=abs(hd-md);
	double c=a*a+b*b-2*a*b*cos(ddeg);
	c=sqrt(c);
	cout<<setprecision(16)<<c<<"\n";
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}