#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979

int main(){
	int a,b,h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	
	double aa=(60*h+m)/720.0*2*PI;
	double bb=m/60.0*2*PI;
	
	printf("%.20f",hypot(a*cos(aa)-b*cos(bb),a*sin(aa)-b*sin(bb)));
}