var lines = [];
var  reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', function (line) {
    lines.push(line);
});

reader.on('close', function () {
    var total = 0;
    var s = lines[0];
    
    var start = 0;
    for (var start = 0; start < s.length; start++) {
        for (var i = 1; i <= s.length; i++) {
            var tmp = parseInt(s.substr(start, i));
            if (tmp !== 0 && tmp % 2019 === 0) {
                total++;
                start = (start + i - 1);
                console.log(tmp);
            }
        }
    }
    
    
    console.log(total);
});