{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Data.IORef
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 n = BC.length str
  forM_ [0..n] $ \i -> do
    let string4 = BC.take 4 $ BC.drop i str
    modifyIORef' count $ if string4 `L.elem` strs4
                              then (+1)
                              else id
    let string5 = BC.take 5 $ BC.drop i str
    modifyIORef' count $ if string5 `L.elem` strs5
                              then (+1)
                              else id
    let string6 = BC.take 6 $ BC.drop i str
    modifyIORef' count $ if string6 `L.elem` strs6
                         then (+1)
                         else id
  n <- readIORef count
  print n
      
strs4 = ["2019","4038","6057","8076"]
strs5 = ["10095","12114","14133","16152","18171","20190","22209","24228","26247","28266","30285","32304","34323","36342","38361","40380","42399","44418","46437","48456","50475","52494","54513","56532","58551","60570","62589","64608","66627","68646","70665","72684","74703","76722","78741","80760","82779","84798","86817","88836","90855","92874","94893","96912","98931"]
strs6 = ["100950","102969","104988","107007","109026","111045","113064","115083","117102","119121","121140","123159","125178","127197","129216","131235","133254","135273","137292","139311","141330","143349","145368","147387","149406","151425","153444","155463","157482","159501","161520","163539","165558","167577","169596","171615","173634","175653","177672","179691","181710","183729","185748","187767","189786","191805","193824","195843","197862","199881"]
