function main(input) {
  const i = input.split('');
  let count = 0;
  let p1 = 0, p2 = 1;
  let str = i[p1];
  while (p1 < i.length) {
    if (p2 >= i.length) {
    	p1++
      	p2 = p1+1;
      	str = str[p1];
      	if (p2 >= i.length) break;
    }
  	str += i[p2];
    if (str.length >= '2019'.length && parseInt(str) % 2019 === 0) {
  	  count++;
      p1 = p2;
      p2 = p1;
      str = i[p1];
    }
    p2++;
  }
  console.log(count);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));