import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Bits
import Data.List
--import qualified  Data.ByteString as B
import Data.Ord
import Data.Array.ST
-- import Data.Array.IO 
import Control.Monad.ST
import Data.List.Extra


bsToInt :: BS.ByteString -> Int
bsToInt = fst . fromJust . BS.readInt

bsToIntList :: BS.ByteString -> [Int]
bsToIntList = map bsToInt . BS.words

main :: IO ()
main = do
    ss <- BS.getLine :: IO BS.ByteString
    let len = BS.length ss
    let t1 = [ bsToInt . BS.take l . BS.drop i $ ss | i<-[0..len-4], l<-[4..len-i]]
    let t2 = filter (\x -> rem x 2019 == 0) t1
    let t3 = length t2
    --print $ t1
    --print $ t2
    print $ t3