#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
 
int main(){
	long long a, b, h, m;
	double r,rad,c;
 
	cin >> a >> b >> h >> m;
 
	r = static_cast<double>(6.0 * m - 0.5 * (h * 60.0 + m));
 
	if(r == 0.0) {
        c = b - a;
        if(c > 0){
          cout << c;
        else{
          cout << -1*C
        }
		
		
		return 0;
	}else if(r == 180.0){
		c = b + a;
		cout << c;
		return 0;
	}else if(r > 180.0){
		r = 360.0 - r;
	}else if(r < 0.0){
		r = 360.0 + r;
	}
 
	rad = static_cast<double>(r * M_PI / 180.0);
 
	c = static_cast<double>(sqrt(static_cast<double>(a*a) + static_cast<double>(b*b) - static_cast<double>(2*a*b*cos(rad))));
 
	cout << fixed << setprecision(20) << c << endl;
}