#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    printf("\n");
    int i,j;
    int d=0;
    char *S=0;
    char t[200000];
    scanf("%c",S);
    for(i=0;i<=200000;i++){
        for(j=i+1;j<=200000;j++){
    strncpy( t, S+i, j-i+1 );
    int k = atoi(S);
            if(k%2019==0){
                d=d+1;
            }
            else{
                d=d;
            }
        }
    }
    printf("%d\n",d);
    
    return 0;
}
    