#include <string.h>
#include <stdlib.h>
#include<stdio.h>
int main()
{
    int count=0;
    int n;
    int check;
    char s[200001];
    char t[200001];
    scanf("%s",s);
    n = strlen(s);
    for(int i = 0; i < n; i++) {
      for(int j = i+3; j < n; j++){
        strncpy( t, s+i, j-i+1 );
        t[j-i+1] = '\0';
        check = atoi(t);
        if(check%2019==0){
          count++;
        }
      }
    }
    printf("%d\n",count);
    return 0;
}