const Main = S => {
  let count = 0;
  for(let i=0; i<=S.length-1; i++) {
    for(let j=i+1; j<=S.length; j++) {
      const num = Number(S.slice(i, j));
      if(num % 2019 === 0) count++;
    }
  }
  console.log(count);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
/*Main(`1817181712114`);
Main(`14282668646`)
Main(`2119`)*/
