import           Control.Monad
import           Control.Monad.ST
import qualified Data.ByteString.Char8        as B
import qualified Data.Vector.Unboxed          as U
import qualified Data.Vector.Algorithms.Radix as U
import qualified Data.Vector                  as V

main :: IO ()
main = do
  s <- B.getLine
  print $ solve s

solve :: B.ByteString -> Int
solve s = U.sum $ U.map (_solve s) object

_solve :: B.ByteString -> Int -> Int
_solve s x = length $ filter (sx `B.isSuffixOf`) $ B.inits s
  where sx = B.pack $ show x

object :: U.Vector Int
object = U.filter p $ U.fromList [2019, 2019*2 .. 200000]
  where
    p x
      | r == 0    = False
      | q == 0    = True
      | otherwise = p q
      where (q, r) = x `divMod` 10

readInts :: IO [Int]
readInts = map read . words <$> getLine

readIntN :: Int ->  IO (U.Vector Int)
readIntN n = U.unfoldrN n (B.readInt . B.dropWhile ((==) ' ')) <$> B.getLine

radixSort :: U.Vector Int -> U.Vector Int
radixSort xs = runST $ do
  mxs <- U.thaw xs
  U.sort mxs
  U.freeze mxs