PROGRAM d164

IMPLICIT NONE
CHARACTER :: S * 200000
INTEGER :: T, i, j, k, l, m

READ * S

DO k = 1, 200000
	IF (S(k:k) == ' ') EXIT
END DO

l = k - 1
m = 0

DO i = 1, l
	DO j = i, l
    	READ (S(i,j) , *) T
        IF (MOD(T,2019) == 0)
        m = m + 1
        END IF
    END DO
END DO

PRINT *, m

END PROGRAM d164