#include<stdio.h>
#include<math.h>

int main(){
    long int n,number;
    int i=0,counter=0,quotient,divider,c;
    do{
       scanf("%d",&n);
    }while(n<0 || n>200000);
    number=n;
    while(n!=0){
          n/=10;i++;
    }
    while(i>0){
        quotient=number/pow(10,--i);
        c=quotient%2019;
        if(c==0){
            number-=quotient*pow(10,i);
            counter++;
        }
    }
    printf("\n%d",counter);
   return 0;
}
