#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 200000
int main() {
    int i, j, l, count = 0;
    long s;
    char S[SIZE];
    scanf("%s", S);
    l = strlen(S);
    s = atol(S);
    while (s > 2018) {
        for (i = l; i > 1; i--) {
            int check = s % (int)pow(10, i);
            if (check % 2019 == 0) {
                count++;
            }
        }
        s /= 10;
        l--;
    }
    printf("%d\n", count);
    return 0;
}