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

int main (void) {
    char s[200001];
    scanf("%s", s);

    long long ans = 0;
    long long s_num;
    int s_len = strlen(s);

    for ( int i=0; i<s_len; i++ ) {
        s_num = strtol(&s[i], NULL, 10);
        while ( s_num >= 12114 ) {
            if ( s_num % 2019 == 0 )
                ans++;
            s_num /= 10;
        }
    }

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}
