program main
	implicit none
	integer(8):: A,B,H,M,i,j,k
	double precision::kai,pi=dacos(-1d0),t,s
	read *, A,B,H,M	
	s=dble(H)+dble(M)/60d0
	t=(30d0*s-6d0*dble(M))
	kai=sqrt(dble(A*A)+dble(B*B)&
		-2d0*dble(A*B)*dcos(t/180d0*pi))
	
	 print '(f0.14)', kai
end program main