const main = (inputs) => {
  var num = inputs[0];
  var sortArray = [];
  var sortObj = new Object;
  var count = 0;

  for (var i = 2019; i < 200000; i = i + 2019) {
    sortObj[i] = 1;
    sortArray.push(i);
  }
  for (var j = 0; j < sortArray.length; j++) {
    if (num.indexOf(sortArray[j]) != -1) {
      count++;
      var moziNum = Number(num.indexOf(sortArray[j])) + String(sortArray[j]).length;
      while (1) {
        var copy = num.slice(moziNum - 1);
        if (copy.indexOf(sortArray[j]) != -1) {
          count++;
        } else {
          break;
        }
        moziNum = moziNum + String(sortArray[j]).length - 1;
      }
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));