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

int main(){
	int H,M,A,B;
	double ans;
	scanf("%d %d %d %d",&A,&B,&H,&M);
	double Ac,Bc,c;
	Ac = 3.14159265359 * 2 * H / 12;
	Bc = 3.14159265359 * 2 * M / 60;
	c = Ac - Bc;
	ans = sqrt(A*A+B*B-2*A*B*cos(c));
	printf("%lf",ans);
}
