#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
	char s[200001] = { '\0' };
	long l = 0;
	long x = 0;
	scanf("%s", s);
	while(s[l] != '\0'){
		l++;
	}
	for(long i=0; i<l-4; i++){
		long j = i + 3;
		while(j<l){
			char *tmp_s;
			tmp_s = (char *)malloc(sizeof(char) * (i+j+2));
			tmp_s = strncpy(tmp_s, s+i, j-i+1);
			tmp_s[i+j+1] = '\0';
			long tmp = atol(tmp_s);
			if(tmp%2019 == 0){
				x++;
				j += 4;
			}
			else{
				j++;
			}
		}
	}
	printf("%ld\n", x);
	return 0;
}