#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>


using namespace std;



int main() {

	const double PI = 3.14159265358979323846;
	double A, B, H, M;
	double x1, x2, y1, y2, angleH, angleM, ans;
	
	cin >> A >> B >> H >> M;

	angleH = -2 * PI * H / 12 + PI / 2 - M * PI / 6 / 60;
	angleM = -2 * PI * M / 60 + PI / 2;

	x1 = A * cos(angleH);
	y1 = A * sin(angleH);
	x2 = B * cos(angleM);
	y2 = B * sin(angleM);

	ans = pow(pow(abs(x2 - x1), 2) + pow(abs(y2 - y1), 2), 0.5);


	cout <<ans;

	return 0;

}	