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

int main(void){
	int A,B,H,M;
	double MIN,thetaA,thetaB;
	double xA,yA,xB,yB,ans;
	char str[100000];
 
	fgets(str, sizeof(str), stdin);
	A=atoi(strtok(str," "));
	B=atoi(strtok(NULL," "));
	H=atoi(strtok(NULL," "));
	M=atoi(strtok(NULL," "));

	MIN=60*H+M;
	thetaA=0.5*MIN*2*3.14159265358979/360;
	thetaB=6.0*MIN*2*3.14159265358979/360;

	xA=A*cos(thetaA);
	xB=B*cos(thetaB);

	yA=A*sin(thetaA);
	yB=B*sin(thetaB);

	ans=sqrt( (xA-xB)*(xA-xB) +(yA-yB)*(yA-yB) );

	printf("%.10lf\n",ans);

	return 0;
}