#include <stdio.h>
#include <string.h>

int main()
{

    char s[200000];
    scanf("%s", s);
    int c = strlen(s);

    long long k;

    int l = 0;

    for (int i = 0; i < c-3; i++)
    {

        k = 100*(s[i]-48)+10*(s[i+1]-48)+s[i+2]-48;   
        for (int j = i+3; j < c; j++)
        {

            k = 10*k+s[j]-48;
            //printf("%lld\n", k);

            if(k%2019==0)
                l++;

        }
    }
    printf("%d", l);
    printf("\n");
}