import Control.Monad
import Data.List
import Data.Char

main = do
    ss <- tails <$> getLine
    print $ sum $ map solve ss

solve s = pred . length . filter (== 0) $ scanl' (\p x -> (10*p + (digitToInt x)) ` mod` 2019) 0 s