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

int main() {
	int n,k,a,b,h,m,i;
	cin >> a >> b >> h >> m;
	double c,d,pi=acos(-1.0);
	d=abs(m*5.5-h*30.0);
	d=min(d,360-d);
	c=sqrt(a*a+b*b-2*a*b*cos(pi*d/180));
	cout << setprecision(10);
	cout << c << endl;
	return 0;
}