let input = require('fs').readFileSync('/dev/stdin', 'utf8')
.split(/\n| /)
// .map(item => parseInt(item))
.slice(0,-1)[0]

let counter = 0

for(let i=0; i<input.length-3; i++){
    for(let j=i+4; j<=input.length; j++){
        const item = parseInt(input.slice(i,j))
        if(item % 2019 === 0) counter++
    }
}

console.log(counter)