{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Data.IORef
import Data.Maybe
import Data.List as L
import Data.ByteString as B
import Data.ByteString.Char8 as BC

main :: IO ()
main = do
  str <- BC.getLine
  count <- newIORef 0 :: IO (IORef Int)
  let len = BC.length str
  forM_ [0..len-4] $ \i -> do
    forM_ [i+1..len] $ \j -> do
      let bs = BC.take (j-i) . BC.drop i $ str
      let num = fromMaybe 0 $ fst <$> BC.readInt bs
      modifyIORef' count $ if num > 2018 && num `mod` 2019 == 0
                           then (+1)
                           else id
  n <- readIORef count
  print n
