#include <stdio.h>
#include <math.h>


int main() {
	int A, B, H, M;
	float PI = 3.14159265359;
	scanf("%d %d %d %d", &A, &B, &H, &M);
	double a, b;
	a = (double)M * 6;
	
	b = (double)H * 30 + M * 0.5;
	double radA, radB;
	radA = (double)(90-a) * PI / 180.0;
	radB = (double)(90-b) * PI / 180.0;
	//printf("%f", radA);
	double ax = A * cos(radA);
	double ay = A * sin(radA);
	double bx = B * cos(radB);
	double by = B * sin(radB);
	//printf("%f %f \n%f %f", ax, ay, bx, by);
	float c =sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
	printf("%lf", c);
	return 0;
}