PROGRAM c168c

IMPLICIT NONE
REAL(8) :: xa, xb, ya, yb, sa, sb, z
INTEGER :: A, B, H, M

READ *, A, B, H, M

sa = 0.5 * (DBLE(H) * 60 + DBLE(M))
sb = 6 * DBLE(M)
xa = DBLE(A) * COS(sa / 180 * 3.141592653589793238)
xb = DBLE(B) * COS(sb / 180 * 3.141592653589793238)
ya = DBLE(A) * SIN(sa / 180 * 3.141592653589793238)
yb = DBLE(B) * SIN(sb / 180 * 3.141592653589793238)
z = ((xa - xb) ** 2.0 + (ya - yb) ** 2.0) ** 0.5

PRINT *, z

END PROGRAM c168c