#include<stdio.h>
int main()
{
  int a,b,c,d;
  int cou=0;
  int digit = 0;
  scanf("%d",&a);
  b=10;
  while(number!=0){
    number = number/10;
    digit++;
  }
  int i,j;
  if(a%2019=0){
    cou++;
  }
  for(i=3;i<digit;i++){
    c=1000;
    for(j=3;j<digit;j++){
      d=a%c;
      if(c%2019=0){
        cou++;
      }
      c=c*10;
    }
    a=a/b;
  }
  printf("%d",cou);
  return 0;
}