import qualified Data.List as L

main :: IO ()
main = do
  s <- getLine
  let s1 = (check s) :: [String]
  let s2 = check2 $ map read s1 :: [Int]
  print $ L.length $ L.nub s2

check s = L.filter (\x -> L.length x >= 4) $ L.subsequences s

check2 s = L.filter (\x -> x `mod` 2019 == 0) s
