function Main(input) {
    var S = input[0];

    var result = 0;

    if (S.length < 4) {
        console.log(0);
        return;
    }

    for (var i = 4; i < S.length; i++) {
        for (var j = 0; j < S.length - i + 1; j++) {
            if (BigInt(S.substring(j, j + i)) % 2019n === 0n) {
                result++;
            }
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));